Class: Sonycam::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/sonycam/cli.rb

Constant Summary collapse

DD_PATH =
File.join(ENV['HOME'], '.sonycam')

Instance Method Summary collapse

Instance Method Details

#api(method, *params) ⇒ Object



48
49
50
# File 'lib/sonycam/cli.rb', line 48

def api method, *params
  puts api_client.request(method, *params).to_json
end

#list(query = nil) ⇒ Object



32
33
34
35
36
# File 'lib/sonycam/cli.rb', line 32

def list query = nil
  apis = api_client.request(:getAvailableApiList).first
  apis.select!{|method| method =~ /#{query}/i } if query
  puts apis
end

#liveviewObject



53
54
55
56
57
58
# File 'lib/sonycam/cli.rb', line 53

def liveview
  liveview_url = api_client.request('startLiveview').first
  Liveview.stream(liveview_url) do |packet|
    puts packet[:payload_data][:jpeg_data]
  end
end

#scan(ip = nil) ⇒ Object



19
20
21
22
23
24
# File 'lib/sonycam/cli.rb', line 19

def scan ip = nil
  location = Scanner.scan(ip).first
  puts "Found location: #{location}"
  File.write File.join(DD_PATH), open(location).read
  puts "Device description file saved to #{DD_PATH}"
end