Class: Foscam::Model::Device

Inherits:
Base
  • Object
show all
Includes:
Singleton
Defined in:
lib/foscam/model/device.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#connect, #initialize, #persisted?

Constructor Details

This class inherits a constructor from Foscam::Model::Base

Instance Attribute Details

#brightnessObject

attr_accessor :name (get_params, set_alias) attr_accessor :name (get_misc, set_misc)



11
12
13
# File 'lib/foscam/model/device.rb', line 11

def brightness
  @brightness
end

#contrastObject

attr_accessor :name (get_params, set_alias) attr_accessor :name (get_misc, set_misc)



11
12
13
# File 'lib/foscam/model/device.rb', line 11

def contrast
  @contrast
end

#orientationObject

attr_accessor :name (get_params, set_alias) attr_accessor :name (get_misc, set_misc)



11
12
13
# File 'lib/foscam/model/device.rb', line 11

def orientation
  @orientation
end

#resolutionObject

attr_accessor :name (get_params, set_alias) attr_accessor :name (get_misc, set_misc)



11
12
13
# File 'lib/foscam/model/device.rb', line 11

def resolution
  @resolution
end

Instance Method Details

#action(value) ⇒ FalseClass, TrueClass

Preform a decoder action

Parameters:

  • value (Symbol)

    The desired motion action to be sent to the camera

Returns:

  • (FalseClass, TrueClass)

    whether the request was successful.



75
76
77
78
# File 'lib/foscam/model/device.rb', line 75

def action(value)
	# have an action map to map some subset to the foscam set
	client.decoder_control(value)
end

#capturenil, ::MiniMagick::Image

Capture the current image

Returns:

  • (nil, ::MiniMagick::Image)


67
68
69
# File 'lib/foscam/model/device.rb', line 67

def capture
	client.snapshot
end

#client=(obj) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/foscam/model/device.rb', line 33

def client=(obj)
	unless obj.nil?
		Device::client = obj
		cam_params = client.get_camera_params
		unless cam_params.empty?
			@resolution = cam_params[:resolution]
			@brightness = cam_params[:brightness]
			@contrast = cam_params[:contrast]
			@orientation = cam_params[:flip]
			# mode
		end
	end
end

#saveFalseClass, TrueClass

Save the current device

Returns:

  • (FalseClass, TrueClass)

    Whether or not the device was successfully saved



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/foscam/model/device.rb', line 52

def save
	run_callbacks :save do
		flag = false
		if changed? && is_valid?
			@previously_changed = changes
			flag = client.camera_control(dirty_params_hash)
			@changed_attributes.clear if flag
		end
		flag
	end
end