class Cradlepoint::NetDevice
Attributes
bytes_in[RW]
bytes_out[RW]
carrier[RW]
connection_state[RW]
data[RW]
dns0[RW]
dns1[RW]
esn[RW]
id[RW]
imei[RW]
info[RW]
ip_address[RW]
ip_mode[RW]
mac[RW]
mode[RW]
name[RW]
netmask[RW]
router[RW]
type[RW]
uptime[RW]
Public Class Methods
new(id = nil, router = nil)
click to toggle source
# File lib/cradlepoint/net_device.rb, line 8 def initialize(id = nil, router = nil) self.id = id self.router = router end
rel_url()
click to toggle source
# File lib/cradlepoint/net_device.rb, line 13 def self.rel_url '/net_devices' end
rel_url_from_router(router_id)
click to toggle source
# File lib/cradlepoint/net_device.rb, line 29 def self.rel_url_from_router(router_id) "/routers/#{ router_id }/net_devices/" end
rel_url_with_id(id)
click to toggle source
# File lib/cradlepoint/net_device.rb, line 21 def self.rel_url_with_id(id) "#{ Cradlepoint::NetDevice.rel_url }/#{ id }" end
Public Instance Methods
assign_attributes_from_blob(blob = {})
click to toggle source
# File lib/cradlepoint/net_device.rb, line 67 def assign_attributes_from_blob(blob = {}) return unless blob and blob.any? self.data = blob self.connection_state = blob[:connection_state] self.bytes_in = blob[:bytes_in] self.bytes_out = blob[:bytes_out] self.carrier = blob[:carrier] self.esn = blob[:esn] self.imei = blob[:imei] self.info = blob[:info] self.ip_address = blob[:ip_address] self.mac = blob[:mac] self.mode = blob[:mode] self.name = blob[:name] self.type = blob[:type] self.uptime = blob[:uptime] self.netmask = blob[:netmask] self.dns0 = blob[:dns0] self.dns1 = blob[:dns1] self.ip_mode = blob[:config][:ipmode] if blob[:config].is_a?(Hash) end
assign_attributes_from_data(options = {})
click to toggle source
# File lib/cradlepoint/net_device.rb, line 47 def assign_attributes_from_data(options = {}) return unless self.data and self.data.any? raw_data = self.data if options[:group] return unless raw_data.is_a?(Array) net_devices = [] raw_data.each do |nd| new_net_device = NetDevice.new(nd[:id], self.id) new_net_device.assign_attributes_from_blob(nd) net_devices << new_net_device end net_devices else assign_attributes_from_blob(raw_data) end end
get_all_from_router()
click to toggle source
# File lib/cradlepoint/net_device.rb, line 37 def get_all_from_router raise 'You must provide an ECM router' if router.nil? self.data = Cradlepoint.make_request(:get, build_url(rel_url_from_router)) assign_attributes_from_data(group: true) end
get_all_from_router_as_hash()
click to toggle source
# File lib/cradlepoint/net_device.rb, line 43 def get_all_from_router_as_hash Cradlepoint.make_request(:get, build_url(rel_url_from_router)) end
rel_url()
click to toggle source
# File lib/cradlepoint/net_device.rb, line 17 def rel_url Cradlepoint::NetDevice.rel_url end
rel_url_from_router()
click to toggle source
# File lib/cradlepoint/net_device.rb, line 33 def rel_url_from_router Cradlepoint::NetDevice.rel_url_from_router(router.id) end
rel_url_with_id()
click to toggle source
# File lib/cradlepoint/net_device.rb, line 25 def rel_url_with_id Cradlepoint::NetDevice.rel_url_with_id(id) end