Class: Brandmaker::Variable

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, config = VariableConfig.new) ⇒ Variable

Returns a new instance of Variable.



7
8
9
10
# File 'lib/brandmaker/variable.rb', line 7

def initialize data, config = VariableConfig.new
  @data = data
  @config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/brandmaker/variable.rb', line 5

def config
  @config
end

Instance Method Details

#dataObject



12
13
14
# File 'lib/brandmaker/variable.rb', line 12

def data
  @data
end

#labelObject



29
30
31
# File 'lib/brandmaker/variable.rb', line 29

def label
  config.label || technical_name.humanize
end

#purposeObject



24
25
26
27
# File 'lib/brandmaker/variable.rb', line 24

def purpose
  # purpose is actually not provided by the api
  @data[:purpose] || config.purpose
end

#technical_nameObject



16
17
18
# File 'lib/brandmaker/variable.rb', line 16

def technical_name
  @data[:technical_name]
end

#type_idObject



33
34
35
# File 'lib/brandmaker/variable.rb', line 33

def type_id
  @data[:variable_type_id]
end

#valueObject



20
21
22
# File 'lib/brandmaker/variable.rb', line 20

def value
  @data[:value]
end