Class: FB::Gcode::GcodeToken
- Inherits:
-
Object
- Object
- FB::Gcode::GcodeToken
- Defined in:
- lib/gcode.rb
Overview
A head/tail pair of a single node of GCode. Ex: R01 = [:R, ‘01’]
Instance Attribute Summary collapse
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tail ⇒ Object
readonly
Returns the value of attribute tail.
Instance Method Summary collapse
-
#initialize(str) ⇒ GcodeToken
constructor
A new instance of GcodeToken.
- #to_sym ⇒ Object
Constructor Details
#initialize(str) ⇒ GcodeToken
Returns a new instance of GcodeToken.
29 30 31 32 |
# File 'lib/gcode.rb', line 29 def initialize(str) nodes = str.scan(/\d+|\D+/) # ["R", "01"] @head, @tail = nodes.shift.to_sym, nodes.join(" ") end |
Instance Attribute Details
#head ⇒ Object (readonly)
Returns the value of attribute head.
27 28 29 |
# File 'lib/gcode.rb', line 27 def head @head end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/gcode.rb', line 27 def name @name end |
#tail ⇒ Object (readonly)
Returns the value of attribute tail.
27 28 29 |
# File 'lib/gcode.rb', line 27 def tail @tail end |
Instance Method Details
#to_sym ⇒ Object
34 35 36 |
# File 'lib/gcode.rb', line 34 def to_sym "#{head}#{tail}".to_sym end |