Class: MetaEnum::Element
- Inherits:
-
Object
- Object
- MetaEnum::Element
- Defined in:
- lib/meta_enum/element.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value, name, data, type) ⇒ Element
constructor
A new instance of Element.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value, name, data, type) ⇒ Element
Returns a new instance of Element.
5 6 7 8 9 10 11 |
# File 'lib/meta_enum/element.rb', line 5 def initialize(value, name, data, type) @value = value @name = name.to_sym @data = data @type = type freeze end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/meta_enum/element.rb', line 3 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/meta_enum/element.rb', line 3 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/meta_enum/element.rb', line 3 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/meta_enum/element.rb', line 3 def value @value end |
Instance Method Details
#==(other) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/meta_enum/element.rb', line 13 def ==(other) equal?(other) || equal?(type[other]) # type[] will raise for certain bad keys. Those are obviously not equal so return false. rescue ArgumentError, KeyError false end |
#inspect ⇒ Object
23 24 25 |
# File 'lib/meta_enum/element.rb', line 23 def inspect "#<#{self.class}: #{name}: #{value.inspect}, data: #{data.inspect}>" end |
#to_s ⇒ Object
21 |
# File 'lib/meta_enum/element.rb', line 21 def to_s; name.to_s; end |