Class: TPPlus::Nodes::SpeedNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/tp_plus/nodes/speed_node.rb

Instance Method Summary collapse

Methods inherited from BaseNode

#can_be_inlined?

Constructor Details

#initialize(speed_hash) ⇒ SpeedNode

Returns a new instance of SpeedNode.



4
5
6
# File 'lib/tp_plus/nodes/speed_node.rb', line 4

def initialize(speed_hash)
  @speed_hash = speed_hash
end

Instance Method Details

#eval(context) ⇒ Object



22
23
24
25
26
# File 'lib/tp_plus/nodes/speed_node.rb', line 22

def eval(context)
  return @speed_hash[:speed] if @speed_hash[:units].nil?

  "#{speed(context)}#{units}"
end

#speed(context) ⇒ Object



8
9
10
# File 'lib/tp_plus/nodes/speed_node.rb', line 8

def speed(context)
  @speed_hash[:speed].eval(context)
end

#unitsObject



12
13
14
15
16
17
18
19
# File 'lib/tp_plus/nodes/speed_node.rb', line 12

def units
  case @speed_hash[:units]
  when "mm/s"
    "mm/sec"
  else
    @speed_hash[:units]
  end
end