Class: Formulaic::Label

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_name, attribute, action) ⇒ Label

Returns a new instance of Label.



5
6
7
8
9
# File 'lib/formulaic/label.rb', line 5

def initialize(model_name, attribute, action)
  @model_name = model_name
  @attribute = attribute
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/formulaic/label.rb', line 3

def action
  @action
end

#attributeObject (readonly)

Returns the value of attribute attribute.



3
4
5
# File 'lib/formulaic/label.rb', line 3

def attribute
  @attribute
end

#model_nameObject (readonly)

Returns the value of attribute model_name.



3
4
5
# File 'lib/formulaic/label.rb', line 3

def model_name
  @model_name
end

Instance Method Details

#to_strObject Also known as: to_s



11
12
13
14
15
16
17
# File 'lib/formulaic/label.rb', line 11

def to_str
  if attribute.is_a?(String)
    attribute
  else
    translate || human_attribute_name || attribute.to_s
  end
end