Class: SimplerStateMachine::Enum
- Inherits:
-
Hash
- Object
- Hash
- SimplerStateMachine::Enum
- Defined in:
- lib/simpler_state_machine/enum.rb
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(*members) ⇒ Enum
constructor
A new instance of Enum.
Constructor Details
#initialize(*members) ⇒ Enum
Returns a new instance of Enum.
3 4 5 6 7 |
# File 'lib/simpler_state_machine/enum.rb', line 3 def initialize(*members) super() @rev = {} members.each_with_index {|m,i| self[i] = m } end |
Instance Method Details
#[](k) ⇒ Object
9 10 11 |
# File 'lib/simpler_state_machine/enum.rb', line 9 def [](k) super || @rev[k] end |
#[]=(k, v) ⇒ Object
13 14 15 16 |
# File 'lib/simpler_state_machine/enum.rb', line 13 def []=(k,v) @rev[v] = k super end |