Skip to content

SixArm/sixarm_ruby_to_id

Repository files navigation

SixArm.com → Ruby →
ToId parses an object to id

Gem Version Build Status Code Climate

Introduction

Convert strings to various kinds of id types and uuid types.

For docs go to http://sixarm.com/sixarm_ruby_to_id/doc

We use this gem to help santize web application inputs, for example HTTP query strings and form input controls.

Want to help? We're happy to get pull requests.

Install

Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_to_id

Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_to_id'

Require

To require the gem in your code:

require 'sixarm_ruby_to_id'

Examples

Cast a string to an integer id:

"100".to_i_id #=> 100

Cast a string to a string UUID and ensure it has the right hex characters and dash locations:

"bbd98640-4c2a-4343-ab6b-0ebd2fec6362".to_uuid

Cast a comma-separated list to string ids:

"a,b,c".to_s_ids #=> ["a", "b", "c"]

Cast a hash of year, month, day to a date id YYYY-MM-DD:

{year: "2000", month: "12", day: "31"}.to_date_id #=> "2000-12-31"

About

SixArm.com » Ruby » Convert from an object to an id, uuid, etc.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages