Sha256: 7507e90dc9cfabc8c5b480350dac3ffbd886d93e5c912cc96d306ee40b6550b7
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
# Rasti::Types [![Gem Version](https://badge.fury.io/rb/rasti-enum.svg)](https://rubygems.org/gems/rasti-enum) [![Build Status](https://travis-ci.org/gabynaiman/rasti-enum.svg?branch=master)](https://travis-ci.org/gabynaiman/rasti-enum) [![Coverage Status](https://coveralls.io/repos/github/gabynaiman/rasti-enum/badge.svg?branch=master)](https://coveralls.io/github/gabynaiman/rasti-enum?branch=master) [![Code Climate](https://codeclimate.com/github/gabynaiman/rasti-enum.svg)](https://codeclimate.com/github/gabynaiman/rasti-enum) Type casting ## Installation Add this line to your application's Gemfile: ```ruby gem 'rasti-enum' ``` And then execute: $ bundle Or install it yourself as: $ gem install rasti-enum ## Definition ```ruby module Colors extend Rasti::Enum module Common def red? false end def green? false end def blue? false end end class Red < Rasti::Enum::Value include Common def red? true end end class Green < Rasti::Enum::Value include Common def green? true end end class Blue < Rasti::Enum::Value include Common def blue? true end end end ``` ## Usage ```ruby Colors.values # => [Colors::Blue.new, Colors::Green.new, Colors::Red.new] Colors.include?('GREEN') # => true Colors.include?('WHITE') # => false Colors['BLUE'].blue? # => true Colors['BLUE'].red? # => false ``` ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/rasti-enum. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rasti-enum-1.0.0 | README.md |