Class: Scad4r::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/scad4r/runner.rb

Defined Under Namespace

Classes: PassThrough

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



11
12
13
14
15
16
# File 'lib/scad4r/runner.rb', line 11

def initialize(options = {})
  @options = {format: :stl,
              constants: {},
              parser: PassThrough.new,
              timed: true}.merge(options)
end

Instance Method Details

#run(path, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/scad4r/runner.rb', line 18

def run(path, options = {})
  net_options = @options.merge(options)

  parser = net_options.fetch(:parser)

  # provide a reasonable default
  net_options = {output: output_file(path, net_options)}.merge(net_options)

  io = shell_out(openscad_invocation(path, net_options))

  result_hash = parser.parse io.read

  result_hash.merge({output: net_options.fetch(:output)})
end