README.md in rekkyo-0.2.0 vs README.md in rekkyo-1.0.0

- old
+ new

@@ -2,11 +2,11 @@ [![Gem Version](https://badge.fury.io/rb/rekkyo.svg)](https://badge.fury.io/rb/rekkyo) [![Build Status](https://travis-ci.org/yujideveloper/rekkyo.svg?branch=master)](https://travis-ci.org/yujideveloper/rekkyo) [![Maintainability](https://api.codeclimate.com/v1/badges/37d6334cedf5b04af831/maintainability)](https://codeclimate.com/github/yujideveloper/rekkyo/maintainability) -Rekkyo is a gem for defining an enumerated type in Ruby. +Rekkyo (列挙) is a gem for defining an enumerated type in Ruby. This gem is inspired by [`Ruby::Enum`](https://github.com/dblock/ruby-enum) and [`Enum`](https://github.com/LIQIDTechnology/enum_class). ## Installation @@ -39,10 +39,28 @@ { color: Color::RED }.to_json # => "{\"color\":\"RED\"} Color::RED.red? # => true Color::BLUE.blue? # => false + +Color::RED == Color::RED # => true +Color::RED == Color::BLUE # => false +Color::RED == :RED # => false +Color::RED == "RED" # => false + +Color::RED === Color::RED # => true +Color::RED === Color::BLUE # => false +Color::RED === :RED # => true +Color::RED === "RED" # => true + +case "RED" +when Color::RED then "#FF0000" +when Color::BLUE then "#00FF00" +when Color::GREEN then "#0000FF" +else "Unkown" +end +# => "#FF0000" ``` ### Custom value ``` ruby @@ -52,10 +70,31 @@ member :RED, "#FF0000" member :GREEN, "#00FF00" member :BLUE, "#0000FF" end +Color::RED.red? # => true +Color::BLUE.blue? # => false + { color: Color::RED }.to_json # => "{\"color\":\"#FF0000\"}" + +Color::RED == Color::RED # => true +Color::RED == Color::BLUE # => false +Color::RED == :"#FF0000" # => false +Color::RED == "#FF0000" # => false + +Color::RED === Color::RED # => true +Color::RED === Color::BLUE # => false +Color::RED === :"#FF0000" # => true +Color::RED === "#FF0000" # => true + +case "#FF0000" +when Color::RED then "RED" +when Color::BLUE then "BLUE" +when Color::GREEN then "GREEN" +else "Unkown" +end +# => "RED" ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.