Class: SonyCameraRemote::Camera

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/sony_camera_remote/camera.rb

Defined Under Namespace

Classes: ApplicationInfo, IncompatibleAPIVersion

Constant Summary collapse

API_VERSION =
'2.0.0'
DEFAULT_OPTIONS =
{:version => '1.0', :params => [], :id => 1}

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Camera

Returns a new instance of Camera.



27
28
29
30
31
32
# File 'lib/sony_camera_remote/camera.rb', line 27

def initialize(uri)
  self.class.base_uri(URI(uri).to_s)

  ai = application_info
  raise IncompatibleAPIVersion(API_VERSION, ai.api_version) if API_VERSION != ai.api_version
end

Instance Method Details

#application_infoObject



44
45
46
47
48
# File 'lib/sony_camera_remote/camera.rb', line 44

def application_info
  options = {:body => DEFAULT_OPTIONS.merge({:method => 'getApplicationInfo'}).to_json}
  result = self.class.post('', options)['result']
  ApplicationInfo.new(result.first, result.last)
end

#available_methodsObject



50
51
52
53
# File 'lib/sony_camera_remote/camera.rb', line 50

def available_methods
  options = {:body => DEFAULT_OPTIONS.merge({:method => 'getAvailableApiList'}).to_json}
  self.class.post('', options)['result'].first
end

#shootObject

blocking



56
57
58
59
# File 'lib/sony_camera_remote/camera.rb', line 56

def shoot
  options = {:body => DEFAULT_OPTIONS.merge({:method => 'actTakePicture'}).to_json}
  self.class.post('', options)['result'].first
end

#shootmodeObject



34
35
36
37
# File 'lib/sony_camera_remote/camera.rb', line 34

def shootmode
  options = {:body => DEFAULT_OPTIONS.merge({:method => 'getShootMode'}).to_json}
  self.class.post('', options)['result'].first
end

#supported_shootmodesObject



39
40
41
42
# File 'lib/sony_camera_remote/camera.rb', line 39

def supported_shootmodes
  options = {:body => DEFAULT_OPTIONS.merge({:method => 'getSupportedShootMode'}).to_json}
  self.class.post('', options)['result'].first
end