Class: Dropcam::Setting

Inherits:
Base
  • Object
show all
Defined in:
lib/dropcam/setting.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#cookies, #session_token

Instance Method Summary collapse

Methods inherited from Base

#delete, #get, #post

Constructor Details

#initialize(name, value, camera) ⇒ Setting

Returns a new instance of Setting.



5
6
7
8
9
# File 'lib/dropcam/setting.rb', line 5

def initialize(name, value, camera)
  @camera = camera
  @name = name
  @current_value = value
end

Instance Attribute Details

#cameraObject

Returns the value of attribute camera.



4
5
6
# File 'lib/dropcam/setting.rb', line 4

def camera
  @camera
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/dropcam/setting.rb', line 4

def name
  @name
end

Instance Method Details

#set(value) ⇒ Object



22
23
24
25
26
27
# File 'lib/dropcam/setting.rb', line 22

def set(value)
  response = post(::DROPCAMS_SET_PROPERTY, {"uuid"=>@camera.uuid, "key" => @name, "value" => value}, @camera.cookies)     
  @current_value = value
  @camera.settings = JSON.parse(response.body)["items"][0]
  true
end

#to_sObject



18
19
20
# File 'lib/dropcam/setting.rb', line 18

def to_s
  "<Dropcam::Setting:#{object_id} @name=#{@name} @value=#{@current_value}>"
end

#valueObject



11
12
13
14
15
16
# File 'lib/dropcam/setting.rb', line 11

def value
  return false if @current_value == 'false'
  return true if @current_value == 'true'
  
  @current_value
end