Module: TypedEnum::TypedEnumClassMethods
- Defined in:
- lib/typed_enum.rb
Instance Method Summary collapse
- #_load(str) ⇒ Object
- #from_name(sym) ⇒ Object
- #init ⇒ Object
- #parse(token) ⇒ Object
- #values ⇒ Object
Instance Method Details
#_load(str) ⇒ Object
61 62 63 |
# File 'lib/typed_enum.rb', line 61 def _load(str) parse(str.to_sym) end |
#from_name(sym) ⇒ Object
48 49 50 |
# File 'lib/typed_enum.rb', line 48 def from_name(sym) inverse_map[sym.to_sym] or raise NameError.new("No mapping for symbol #{sym} to vertical") end |
#init ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/typed_enum.rb', line 66 def init if !@initialized @initialized = true @@values = @enum.call else raise "Attempt to re-initialize typed enum #{self.class}" end end |
#parse(token) ⇒ Object
52 53 54 55 |
# File 'lib/typed_enum.rb', line 52 def parse(token) sym = token.to_sym from_symbol(sym) end |
#values ⇒ Object
57 58 59 |
# File 'lib/typed_enum.rb', line 57 def values @@values end |