Class: ClassyEnumValue

Inherits:
Object
  • Object
show all
Defined in:
lib/classy_enum.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_classObject (readonly)

Returns the value of attribute base_class.



6
7
8
# File 'lib/classy_enum.rb', line 6

def base_class
  @base_class
end

#indexObject (readonly)

Returns the value of attribute index.



6
7
8
# File 'lib/classy_enum.rb', line 6

def index
  @index
end

#to_sObject (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_symObject (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

#nameObject



15
16
17
# File 'lib/classy_enum.rb', line 15

def name
  to_s.titleize
end