Class: MonogotoApi::Thing
- Inherits:
-
Object
- Object
- MonogotoApi::Thing
- Defined in:
- lib/monogoto_api/thing.rb
Overview
Thing refer to Monogoto SIM
Instance Attribute Summary collapse
-
#iccid ⇒ Object
readonly
Returns the value of attribute iccid.
-
#imei ⇒ Object
readonly
Returns the value of attribute imei.
-
#ips ⇒ Object
readonly
Returns the value of attribute ips.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**attributes) ⇒ Thing
constructor
A new instance of Thing.
- #ip ⇒ Object
Constructor Details
#initialize(**attributes) ⇒ Thing
Returns a new instance of Thing.
8 9 10 11 12 13 14 15 |
# File 'lib/monogoto_api/thing.rb', line 8 def initialize(**attributes) @iccid = attributes[:iccid] @imei = attributes[:imei] @operator = attributes[:operator] @state = attributes[:state] @name = attributes[:name] @ips = attributes[:ips] end |
Instance Attribute Details
#iccid ⇒ Object (readonly)
Returns the value of attribute iccid.
6 7 8 |
# File 'lib/monogoto_api/thing.rb', line 6 def iccid @iccid end |
#imei ⇒ Object (readonly)
Returns the value of attribute imei.
6 7 8 |
# File 'lib/monogoto_api/thing.rb', line 6 def imei @imei end |
#ips ⇒ Object (readonly)
Returns the value of attribute ips.
6 7 8 |
# File 'lib/monogoto_api/thing.rb', line 6 def ips @ips end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/monogoto_api/thing.rb', line 6 def name @name end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
6 7 8 |
# File 'lib/monogoto_api/thing.rb', line 6 def operator @operator end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
6 7 8 |
# File 'lib/monogoto_api/thing.rb', line 6 def state @state end |
Class Method Details
.parse(hash_thing) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/monogoto_api/thing.rb', line 25 def self.parse(hash_thing) ips = MonogotoApi::IP.parse_many(hash_thing["IPs"]) new( imei: hash_thing["IMEI"], name: hash_thing["ThingName"], iccid: hash_thing["ExternalUniqueId"], operator: hash_thing["MnoName"], state: hash_thing["State"], ips: ) end |
.parse_many(response) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/monogoto_api/thing.rb', line 17 def self.parse_many(response) output = [] response.each do |pre_thing| output.push(parse(pre_thing)) end output end |
Instance Method Details
#ip ⇒ Object
37 38 39 |
# File 'lib/monogoto_api/thing.rb', line 37 def ip @ips.first.ip end |