Java-style enums brought over to Ruby and CoffeeScript
Add this line to your application's Gemfile:
gem 'jiffy_enums'
And then execute:
$ bundle
Class MyEnums < JiffyEnum
define :ENUM1, 'enum 1'
define :ENUM2, 'enum 2'
define :ENUM3, 'enum 3'
end
MyEnums[:ENUM1].key
=> :ENUM1
MyEnums[:ENUM1].value
=> "enum 1"
MyEnums[:ENUM1].ordinal
=> 1
MyEnums::ENUM2
=> "enum 2"
Enums = {}
<%= MyEnums.to_coffee('Enums') %>
Enums.MyEnums.get('ENUM1').key
=> "ENUM1"
Enums.MyEnums.get('ENUM1').value
=> "enum 1"
Enums.MyEnums.get('ENUM1').ordinal
=> 1
=>
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request