Class: EnumerableConstant::Tupple

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/spree_core/enumerable_constants.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value = nil, display_name = nil) ⇒ Tupple

Returns a new instance of Tupple.



19
20
21
22
23
# File 'lib/spree_core/enumerable_constants.rb', line 19

def initialize(name, value=nil, display_name=nil)
  @name = name
  @value = value
  @display_name = display_name
end

Instance Attribute Details

#display_nameObject

Returns the value of attribute display_name.



17
18
19
# File 'lib/spree_core/enumerable_constants.rb', line 17

def display_name
  @display_name
end

#nameObject

Returns the value of attribute name.



17
18
19
# File 'lib/spree_core/enumerable_constants.rb', line 17

def name
  @name
end

#valueObject

Returns the value of attribute value.



17
18
19
# File 'lib/spree_core/enumerable_constants.rb', line 17

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



25
26
27
# File 'lib/spree_core/enumerable_constants.rb', line 25

def <=> other
  self.display_name <=> other.display_name
end

#idObject



41
42
43
# File 'lib/spree_core/enumerable_constants.rb', line 41

def id
  self.value
end

#titleObject



33
34
35
36
37
38
39
# File 'lib/spree_core/enumerable_constants.rb', line 33

def title
  if @display_name
    self.display_name
  else
    self.name.titleize.strip
  end
end

#title_translatedObject



29
30
31
# File 'lib/spree_core/enumerable_constants.rb', line 29

def title_translated
  t("order_status_#{self.name.downcase}")
end