class FB::Gcode::GcodeToken
A head/tail pair of a single node of GCode. Ex: R01 = [:R, ‘01’]
Attributes
head[R]
tail[R]
Public Class Methods
new(str)
click to toggle source
# File lib/gcode.rb, line 52 def initialize(str) nodes = str.scan(/[a-zA-Z]+|\-?\d+/) # ["R", "-19"], ["Z", "4"] @head, @tail = nodes.shift.to_sym, nodes.join(" ") # Coerce to ints if possible, since serial line is all string types. @tail = @tail.to_i if @tail.match(/^\-?\d+$/) end
Public Instance Methods
to_s()
click to toggle source
# File lib/gcode.rb, line 64 def to_s "#{head}#{tail}" end
to_sym()
click to toggle source
# File lib/gcode.rb, line 60 def to_sym to_s.to_sym end