Class: RintCore::GCode::Object

Inherits:
Object
  • Object
show all
Includes:
Codes
Defined in:
lib/rint_core/g_code/object.rb

Constant Summary

Constants included from Codes

Codes::ABS_EXT_MODE, Codes::ABS_POSITIONING, Codes::COMMENT_SYMBOL, Codes::CONTROLLED_MOVE, Codes::DISABLE_MOTORS, Codes::DWELL, Codes::EMRG_STOP, Codes::ENABLE_MOTORS, Codes::FAN_OFF, Codes::FAN_ON, Codes::GET_EXT_TEMP, Codes::GET_FW_DETAILS, Codes::GET_POSITION, Codes::HEAD_OFFSET, Codes::HOME, Codes::IDLE_HOLD_OFF, Codes::INIT_SD, Codes::LIST_SD, Codes::PAUSE_SD_PRINT, Codes::POWER_OFF, Codes::POWER_ON, Codes::RAPID_MOVE, Codes::RELEASE_SD, Codes::REL_EXT_MODE, Codes::REL_POSITIONING, Codes::SD_PRINT_STATUS, Codes::SELECT_SD_FILE, Codes::SET_BED_TEMP_NW, Codes::SET_BED_TEMP_W, Codes::SET_EXT_TEMP_NW, Codes::SET_EXT_TEMP_W, Codes::SET_LINE_NUM, Codes::SET_POSITION, Codes::SET_SD_POSITION, Codes::SLEEP, Codes::START_SD_PRINT, Codes::START_SD_WRITE, Codes::STOP, Codes::STOP_SD_WRITE, Codes::USE_INCHES, Codes::USE_MILLIMETRES, Codes::WIAT_FOR_TEMP

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ Object

Returns a new instance of Object.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rint_core/g_code/object.rb', line 15

def initialize(data = nil)
  if data.class == String && self.class.is_file?(data)
    data = self.class.get_file(data)
  end
  return false if data.blank? || data.class != Array
  @raw_data = data
  @imperial = false
  @relative = false
  @lines = []
  data.each do |line|
    line = RintCore::GCode::Line.new(line)
    @lines << line if line.raw.present?
  end
  process
end

Instance Attribute Details

#depthObject (readonly)

Returns the value of attribute depth.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def depth
  @depth
end

#e_travelObject (readonly)

Returns the value of attribute e_travel.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def e_travel
  @e_travel
end

#filament_usedObject (readonly)

Returns the value of attribute filament_used.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def filament_used
  @filament_used
end

#heightObject (readonly)

Returns the value of attribute height.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def height
  @height
end

#layersObject

Returns the value of attribute layers.



10
11
12
# File 'lib/rint_core/g_code/object.rb', line 10

def layers
  @layers
end

#linesObject (readonly)

Returns the value of attribute lines.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def lines
  @lines
end

#raw_dataObject

Returns the value of attribute raw_data.



10
11
12
# File 'lib/rint_core/g_code/object.rb', line 10

def raw_data
  @raw_data
end

#widthObject (readonly)

Returns the value of attribute width.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def width
  @width
end

#x_maxObject (readonly)

Returns the value of attribute x_max.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def x_max
  @x_max
end

#x_minObject (readonly)

Returns the value of attribute x_min.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def x_min
  @x_min
end

#x_travelObject (readonly)

Returns the value of attribute x_travel.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def x_travel
  @x_travel
end

#y_maxObject (readonly)

Returns the value of attribute y_max.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def y_max
  @y_max
end

#y_minObject (readonly)

Returns the value of attribute y_min.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def y_min
  @y_min
end

#y_travelObject (readonly)

Returns the value of attribute y_travel.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def y_travel
  @y_travel
end

#z_maxObject (readonly)

Returns the value of attribute z_max.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def z_max
  @z_max
end

#z_minObject (readonly)

Returns the value of attribute z_min.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def z_min
  @z_min
end

#z_travelObject (readonly)

Returns the value of attribute z_travel.



11
12
13
# File 'lib/rint_core/g_code/object.rb', line 11

def z_travel
  @z_travel
end

Class Method Details

.get_file(file) ⇒ Object



35
36
37
# File 'lib/rint_core/g_code/object.rb', line 35

def self.get_file(file)
  IO.readlines(file)
end

.is_file?(file) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rint_core/g_code/object.rb', line 31

def self.is_file?(file)
  file.present? && File.exist?(file) && File.file?(file)
end