Class: Prremote::Commands::Ls

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

Constant Summary collapse

QUERY_MAGIC =
'QURY'.freeze

Instance Method Summary collapse

Methods included from SerialHelpers

#normalize, #wait_for_ready

Constructor Details

#initialize(port:, baud:) ⇒ Ls

Returns a new instance of Ls.



10
11
12
13
# File 'lib/prremote/commands/ls.rb', line 10

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

Instance Method Details

#callObject



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

def call
  result = query_device
  if result
    ts_str = if result[:timestamp].positive?
               Time.at(result[:timestamp]).strftime('%Y-%m-%d %H:%M:%S')
             else
               '(unknown)'
             end
    puts 'Deployed script:'
    puts "  Files:    #{result[:names]}"
    puts "  Deployed: #{ts_str}"
  else
    puts 'No script deployed.'
  end
end