Class: Romanesco::VariableOperand

Inherits:
Operand show all
Defined in:
lib/romanesco/elements/variable_operand.rb

Instance Attribute Summary collapse

Attributes inherited from Expression

#parent

Instance Method Summary collapse

Methods inherited from Operand

#connect

Constructor Details

#initialize(name) ⇒ VariableOperand

Returns a new instance of VariableOperand.



10
11
12
# File 'lib/romanesco/elements/variable_operand.rb', line 10

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/romanesco/elements/variable_operand.rb', line 8

def name
  @name
end

Instance Method Details

#evaluate(options) ⇒ Object



14
15
16
17
18
# File 'lib/romanesco/elements/variable_operand.rb', line 14

def evaluate(options)
  element = options[@name.to_sym]
  return element.evaluate(options) if element.respond_to?(:evaluate)
  options[@name.to_sym].to_f if element.is_a? Numeric
end

#to_sObject



20
21
22
# File 'lib/romanesco/elements/variable_operand.rb', line 20

def to_s
  @name.to_s
end