Class: ClassyEnumValue
- Inherits:
-
Object
- Object
- ClassyEnumValue
- Defined in:
- lib/classy_enum.rb
Instance Attribute Summary collapse
-
#base_class ⇒ Object
readonly
Returns the value of attribute base_class.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#to_s ⇒ Object
readonly
Returns the value of attribute to_s.
-
#to_sym ⇒ Object
readonly
Returns the value of attribute to_sym.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(base_class, option, index) ⇒ ClassyEnumValue
constructor
A new instance of ClassyEnumValue.
- #name ⇒ Object
Constructor Details
#initialize(base_class, option, index) ⇒ ClassyEnumValue
Returns a new instance of ClassyEnumValue.
8 9 10 11 12 13 |
# File 'lib/classy_enum.rb', line 8 def initialize(base_class, option, index) @to_s = option.to_s.downcase @to_sym = @to_s.to_sym @index = index + 1 @base_class = base_class end |
Instance Attribute Details
#base_class ⇒ Object (readonly)
Returns the value of attribute base_class.
6 7 8 |
# File 'lib/classy_enum.rb', line 6 def base_class @base_class end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/classy_enum.rb', line 6 def index @index end |
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
6 7 8 |
# File 'lib/classy_enum.rb', line 6 def to_s @to_s end |
#to_sym ⇒ Object (readonly)
Returns the value of attribute to_sym.
6 7 8 |
# File 'lib/classy_enum.rb', line 6 def to_sym @to_sym end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 |
# File 'lib/classy_enum.rb', line 19 def <=> other @index <=> other.index end |
#name ⇒ Object
15 16 17 |
# File 'lib/classy_enum.rb', line 15 def name to_s.titleize end |