Class: EPluribusEnum::Enum
- Inherits:
-
Object
- Object
- EPluribusEnum::Enum
- Defined in:
- lib/e_pluribus_enum/enum.rb
Class Method Summary collapse
- .[](key) ⇒ Object
- .add_item(key, value) ⇒ Object
- .const_missing(key) ⇒ Object
- .each ⇒ Object
- .for_queries(arr) ⇒ Object
- .key_for_value(value) ⇒ Object
- .keys ⇒ Object
- .value_for_key(key) ⇒ Object
- .values ⇒ Object
Class Method Details
.[](key) ⇒ Object
24 25 26 |
# File 'lib/e_pluribus_enum/enum.rb', line 24 def Enum.[](key) @hash[key] end |
.add_item(key, value) ⇒ Object
3 4 5 6 |
# File 'lib/e_pluribus_enum/enum.rb', line 3 def Enum.add_item(key,value) @hash ||= {} @hash[key]=value end |
.const_missing(key) ⇒ Object
8 9 10 |
# File 'lib/e_pluribus_enum/enum.rb', line 8 def Enum.const_missing(key) @hash[key] end |
.each ⇒ Object
12 13 14 |
# File 'lib/e_pluribus_enum/enum.rb', line 12 def Enum.each @hash.each {|key,value| yield(key,value)} end |
.for_queries(arr) ⇒ Object
36 37 38 |
# File 'lib/e_pluribus_enum/enum.rb', line 36 def Enum.for_queries(arr) ret = arr.collect{ |x| @hash[x.to_s.to_sym] } end |
.key_for_value(value) ⇒ Object
32 33 34 |
# File 'lib/e_pluribus_enum/enum.rb', line 32 def Enum.key_for_value(value) @hash.invert[value] end |
.keys ⇒ Object
20 21 22 |
# File 'lib/e_pluribus_enum/enum.rb', line 20 def Enum.keys @hash.keys || [] end |
.value_for_key(key) ⇒ Object
28 29 30 |
# File 'lib/e_pluribus_enum/enum.rb', line 28 def Enum.value_for_key(key) @hash[key] end |
.values ⇒ Object
16 17 18 |
# File 'lib/e_pluribus_enum/enum.rb', line 16 def Enum.values @hash.values || [] end |