Class: CreateGCodeFromGCodeArray

Inherits:
Object
  • Object
show all
Defined in:
lib/convert_svg_string_to_gcode/helpers/create_gcode_from_gcode_array.rb

Class Method Summary collapse

Class Method Details

.perform(gcode_array, options = { header: PlotterConfig::HEADER, footer: PlotterConfig::FOOTER, }) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/convert_svg_string_to_gcode/helpers/create_gcode_from_gcode_array.rb', line 3

def self.perform(
    gcode_array,
    options = {
      header: PlotterConfig::HEADER,
      footer: PlotterConfig::FOOTER,
    }
  )

  header = options.fetch(:header)
  footer = options.fetch(:footer)

  flattened_gcode_array = header + gcode_array.flatten + footer
  flattened_gcode_array.join("\n")

end