Class: Foscam::Model::Network

Inherits:
Base
  • Object
show all
Includes:
Singleton
Defined in:
lib/foscam/model/network.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

#dnsObject

Returns the value of attribute dns.



7
8
9
# File 'lib/foscam/model/network.rb', line 7

def dns
  @dns
end

#gatewayObject

Returns the value of attribute gateway.



7
8
9
# File 'lib/foscam/model/network.rb', line 7

def gateway
  @gateway
end

#ip_addressObject

Returns the value of attribute ip_address.



7
8
9
# File 'lib/foscam/model/network.rb', line 7

def ip_address
  @ip_address
end

#maskObject

Returns the value of attribute mask.



7
8
9
# File 'lib/foscam/model/network.rb', line 7

def mask
  @mask
end

#portObject

Returns the value of attribute port.



7
8
9
# File 'lib/foscam/model/network.rb', line 7

def port
  @port
end

Instance Method Details

#client=(obj) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/foscam/model/network.rb', line 37

def client=(obj)
	unless obj.nil?
		Network::client = obj
		params = client.get_params
		unless params.empty?
			self.ip_address = params[:ip]
			self.mask = params[:mask]
			self.gateway = params[:gateway]
			self.dns = params[:dns]
			self.port = params[:port]
		end
	end
end

#saveObject



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

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