Class: GCoder::GCode::ProgramContext
- Defined in:
- lib/gcoder/gcode.rb
Instance Attribute Summary collapse
-
#absolute ⇒ Object
Returns the value of attribute absolute.
-
#feedrate ⇒ Object
Returns the value of attribute feedrate.
-
#position ⇒ Object
Returns the value of attribute position.
-
#units ⇒ Object
Returns the value of attribute units.
Instance Method Summary collapse
- #absolute? ⇒ Boolean
-
#initialize(position = [0,0,0], feedrate = 0, units = :mm, absolute = false) ⇒ ProgramContext
constructor
A new instance of ProgramContext.
- #update_feedrate(feedrate) ⇒ Object
- #update_position(pos) ⇒ Object
Constructor Details
#initialize(position = [0,0,0], feedrate = 0, units = :mm, absolute = false) ⇒ ProgramContext
Returns a new instance of ProgramContext.
30 31 32 33 34 35 36 37 |
# File 'lib/gcoder/gcode.rb', line 30 def initialize(position = [0,0,0], feedrate = 0, units = :mm, absolute = false) super({}) @position = position @feedrate = feedrate @units = units @absolute = absolute end |
Instance Attribute Details
#absolute ⇒ Object
Returns the value of attribute absolute.
28 29 30 |
# File 'lib/gcoder/gcode.rb', line 28 def absolute @absolute end |
#feedrate ⇒ Object
Returns the value of attribute feedrate.
28 29 30 |
# File 'lib/gcoder/gcode.rb', line 28 def feedrate @feedrate end |
#position ⇒ Object
Returns the value of attribute position.
28 29 30 |
# File 'lib/gcoder/gcode.rb', line 28 def position @position end |
#units ⇒ Object
Returns the value of attribute units.
28 29 30 |
# File 'lib/gcoder/gcode.rb', line 28 def units @units end |
Instance Method Details
#absolute? ⇒ Boolean
39 |
# File 'lib/gcoder/gcode.rb', line 39 def absolute?; absolute; end |
#update_feedrate(feedrate) ⇒ Object
49 50 51 |
# File 'lib/gcoder/gcode.rb', line 49 def update_feedrate(feedrate) @feedrate = feedrate unless feedrate.nil? end |
#update_position(pos) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/gcoder/gcode.rb', line 41 def update_position(pos) if absolute @position = @position.each_with_index.map {|e, i| pos[i] || @position[i] } else @position = @position.each_with_index.map {|e, i| @position[i] + (pos[i] || 0) } end end |