Class: Dimensional::Enum::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/dimensional/enum/attribute.rb

Instance Method Summary collapse

Constructor Details

#initialize(enum_attr_key, enum_attribute) ⇒ Attribute

Returns a new instance of Attribute.



5
6
7
8
# File 'lib/dimensional/enum/attribute.rb', line 5

def initialize( enum_attr_key, enum_attribute )
  @enum_attr_key  = enum_attr_key
  @enum_attribute = enum_attribute
end

Instance Method Details

#==(other) ⇒ Object



10
11
12
# File 'lib/dimensional/enum/attribute.rb', line 10

def ==( other )
  to_s == other
end

#idObject Also known as: value



14
15
16
17
18
# File 'lib/dimensional/enum/attribute.rb', line 14

def id
  @enum_attribute[label][:id]
rescue
  nil
end

#labelObject



26
27
28
29
30
# File 'lib/dimensional/enum/attribute.rb', line 26

def label
  @enum_attr_key.to_sym
rescue
  nil
end

#nameObject



20
21
22
23
24
# File 'lib/dimensional/enum/attribute.rb', line 20

def name
  @enum_attribute[label][:name]
rescue
  nil
end

#to_iObject



40
41
42
# File 'lib/dimensional/enum/attribute.rb', line 40

def to_i
  id.to_i
end

#to_sObject



32
33
34
# File 'lib/dimensional/enum/attribute.rb', line 32

def to_s
  label.to_s
end

#to_symObject



36
37
38
# File 'lib/dimensional/enum/attribute.rb', line 36

def to_sym
  label.to_sym
end