class Foscam::Model::Device

Constants

client

Attributes

brightness[R]

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

contrast[R]

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

orientation[R]

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

resolution[R]

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

Public Instance Methods

action(value) click to toggle source

Preform a decoder action @param value [Symbol] The desired motion action to be sent to the camera @return [FalseClass,TrueClass] whether the request was successful.

# 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
brightness=(val) click to toggle source
# File lib/foscam/model/device.rb, line 18
def brightness=(val)
        brightness_will_change! unless val == @brightness
        @brightness = val
end
capture() click to toggle source

Capture the current image @return [nil, ::MiniMagick::Image]

# File lib/foscam/model/device.rb, line 67
def capture
        client.snapshot
end
client=(obj) click to toggle source
# 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
contrast=(val) click to toggle source
# File lib/foscam/model/device.rb, line 23
def contrast=(val)
        contrast_will_change! unless val == @contrast
        @contrast = val
end
orientation=(val) click to toggle source
# File lib/foscam/model/device.rb, line 28
def orientation=(val)
        orientation_will_change! unless val == @orientation
        @orientation = val
end
resolution=(val) click to toggle source
# File lib/foscam/model/device.rb, line 13
def resolution=(val)
        resolution_will_change! unless val == @resolution
        @resolution = val
end
save() click to toggle source

Save the current device @return [FalseClass, TrueClass] Whether or not the device was successfully saved

# 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

Private Instance Methods

dirty_params_hash() click to toggle source
# File lib/foscam/model/device.rb, line 82
def dirty_params_hash
        h = {}
        h.merge!({:resolution => @resolution}) if resolution_changed?
        h.merge!({:brightness => @brightness}) if brightness_changed?
        h.merge!({:contrast => @contrast}) if contrast_changed?
        h.merge!({:flip => @orientation}) if orientation_changed?
        h
end