Class: Prremote::Commands::Run

Inherits:
Object
  • Object
show all
Includes:
SerialHelpers
Defined in:
lib/prremote/commands/run.rb

Instance Method Summary collapse

Methods included from SerialHelpers

#normalize, #wait_for_ready

Constructor Details

#initialize(port:, baud:) ⇒ Run

Returns a new instance of Run.



11
12
13
14
# File 'lib/prremote/commands/run.rb', line 11

def initialize(port:, baud:)
  @port = port
  @baud = baud
end

Instance Method Details

#call(*rb_paths) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/prremote/commands/run.rb', line 16

def call(*rb_paths)
  rb_paths.each { |f| raise "File not found: #{f}" unless File.exist?(f) }

  warn "Compiling #{rb_paths.map { |f| File.basename(f) }.join(', ')}..."
  mrb_data = compile(*rb_paths)

  warn 'Running...'
  run_on_device(mrb_data)
rescue Interrupt
  warn ''
end