Class: Cradlepoint::NetDevice
- Inherits:
-
CradlepointObject
- Object
- CradlepointObject
- Cradlepoint::NetDevice
- Defined in:
- lib/cradlepoint/net_device.rb
Instance Attribute Summary collapse
-
#bytes_in ⇒ Object
Returns the value of attribute bytes_in.
-
#bytes_out ⇒ Object
Returns the value of attribute bytes_out.
-
#carrier ⇒ Object
Returns the value of attribute carrier.
-
#connection_state ⇒ Object
Returns the value of attribute connection_state.
-
#data ⇒ Object
Returns the value of attribute data.
-
#dns0 ⇒ Object
Returns the value of attribute dns0.
-
#dns1 ⇒ Object
Returns the value of attribute dns1.
-
#esn ⇒ Object
Returns the value of attribute esn.
-
#id ⇒ Object
Returns the value of attribute id.
-
#imei ⇒ Object
Returns the value of attribute imei.
-
#info ⇒ Object
Returns the value of attribute info.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#ip_mode ⇒ Object
Returns the value of attribute ip_mode.
-
#mac ⇒ Object
Returns the value of attribute mac.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#name ⇒ Object
Returns the value of attribute name.
-
#netmask ⇒ Object
Returns the value of attribute netmask.
-
#router ⇒ Object
Returns the value of attribute router.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uptime ⇒ Object
Returns the value of attribute uptime.
Class Method Summary collapse
Instance Method Summary collapse
- #assign_attributes_from_blob(blob = {}) ⇒ Object
- #assign_attributes_from_data(options = {}) ⇒ Object
- #get_all_from_router ⇒ Object
- #get_all_from_router_as_hash ⇒ Object
-
#initialize(id = nil, router = nil) ⇒ NetDevice
constructor
A new instance of NetDevice.
- #rel_url ⇒ Object
- #rel_url_from_router ⇒ Object
- #rel_url_with_id ⇒ Object
Methods inherited from CradlepointObject
build_new_url, #build_new_url, #build_url, build_url, ecm_object_blob?, #ecm_object_blob?, #params, #successful_response?, successful_response?
Constructor Details
#initialize(id = nil, router = nil) ⇒ NetDevice
Returns a new instance of NetDevice.
8 9 10 11 |
# File 'lib/cradlepoint/net_device.rb', line 8 def initialize(id = nil, router = nil) self.id = id self.router = router end |
Instance Attribute Details
#bytes_in ⇒ Object
Returns the value of attribute bytes_in.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def bytes_in @bytes_in end |
#bytes_out ⇒ Object
Returns the value of attribute bytes_out.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def bytes_out @bytes_out end |
#carrier ⇒ Object
Returns the value of attribute carrier.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def carrier @carrier end |
#connection_state ⇒ Object
Returns the value of attribute connection_state.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def connection_state @connection_state end |
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def data @data end |
#dns0 ⇒ Object
Returns the value of attribute dns0.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def dns0 @dns0 end |
#dns1 ⇒ Object
Returns the value of attribute dns1.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def dns1 @dns1 end |
#esn ⇒ Object
Returns the value of attribute esn.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def esn @esn end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def id @id end |
#imei ⇒ Object
Returns the value of attribute imei.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def imei @imei end |
#info ⇒ Object
Returns the value of attribute info.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def info @info end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def ip_address @ip_address end |
#ip_mode ⇒ Object
Returns the value of attribute ip_mode.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def ip_mode @ip_mode end |
#mac ⇒ Object
Returns the value of attribute mac.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def mac @mac end |
#mode ⇒ Object
Returns the value of attribute mode.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def mode @mode end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def name @name end |
#netmask ⇒ Object
Returns the value of attribute netmask.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def netmask @netmask end |
#router ⇒ Object
Returns the value of attribute router.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def router @router end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def type @type end |
#uptime ⇒ Object
Returns the value of attribute uptime.
4 5 6 |
# File 'lib/cradlepoint/net_device.rb', line 4 def uptime @uptime end |
Class Method Details
.rel_url ⇒ Object
13 14 15 |
# File 'lib/cradlepoint/net_device.rb', line 13 def self.rel_url '/net_devices' end |
.rel_url_from_router(router_id) ⇒ Object
29 30 31 |
# 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) ⇒ Object
21 22 23 |
# File 'lib/cradlepoint/net_device.rb', line 21 def self.rel_url_with_id(id) "#{ Cradlepoint::NetDevice.rel_url }/#{ id }" end |
Instance Method Details
#assign_attributes_from_blob(blob = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# 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 = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cradlepoint/net_device.rb', line 47 def assign_attributes_from_data( = {}) return unless self.data and self.data.any? raw_data = self.data if [: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 ⇒ Object
37 38 39 40 41 |
# 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 ⇒ Object
43 44 45 |
# 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 ⇒ Object
17 18 19 |
# File 'lib/cradlepoint/net_device.rb', line 17 def rel_url Cradlepoint::NetDevice.rel_url end |
#rel_url_from_router ⇒ Object
33 34 35 |
# 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 ⇒ Object
25 26 27 |
# File 'lib/cradlepoint/net_device.rb', line 25 def rel_url_with_id Cradlepoint::NetDevice.rel_url_with_id(id) end |