Class: SimplerStateMachine::Enum

Inherits:
Hash
  • Object
show all
Defined in:
lib/simpler_state_machine/enum.rb

Instance Method Summary collapse

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