Class: MonogotoApi::Ping
- Inherits:
-
Object
- Object
- MonogotoApi::Ping
- Defined in:
- lib/monogoto_api/ping.rb,
lib/monogoto_api/ping/list.rb
Defined Under Namespace
Classes: List
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#packet_loss ⇒ Object
readonly
Returns the value of attribute packet_loss.
-
#received ⇒ Object
readonly
Returns the value of attribute received.
-
#sent ⇒ Object
readonly
Returns the value of attribute sent.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Class Method Summary collapse
-
.parse(hash_ping) ⇒ Object
Parser of single element of API ping response.
- .parse_many(response) ⇒ Object
Instance Method Summary collapse
-
#initialize(**attributes) ⇒ Ping
constructor
A new instance of Ping.
Constructor Details
#initialize(**attributes) ⇒ Ping
Returns a new instance of Ping.
7 8 9 10 11 12 13 14 15 |
# File 'lib/monogoto_api/ping.rb', line 7 def initialize(**attributes) @host = attributes[:host] @size = attributes[:size] @ttl = attributes[:ttl] @time = attributes[:time] @sent = attributes[:sent] @received = attributes[:received] @packet_loss = attributes[:packet_loss] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/monogoto_api/ping.rb', line 5 def host @host end |
#packet_loss ⇒ Object (readonly)
Returns the value of attribute packet_loss.
5 6 7 |
# File 'lib/monogoto_api/ping.rb', line 5 def packet_loss @packet_loss end |
#received ⇒ Object (readonly)
Returns the value of attribute received.
5 6 7 |
# File 'lib/monogoto_api/ping.rb', line 5 def received @received end |
#sent ⇒ Object (readonly)
Returns the value of attribute sent.
5 6 7 |
# File 'lib/monogoto_api/ping.rb', line 5 def sent @sent end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
5 6 7 |
# File 'lib/monogoto_api/ping.rb', line 5 def size @size end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/monogoto_api/ping.rb', line 5 def time @time end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
5 6 7 |
# File 'lib/monogoto_api/ping.rb', line 5 def ttl @ttl end |
Class Method Details
.parse(hash_ping) ⇒ Object
Parser of single element of API ping response
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/monogoto_api/ping.rb', line 26 def self.parse(hash_ping) new( host: hash_ping["host"], size: hash_ping["size"].to_i, ttl: hash_ping["ttl"].to_i, time: hash_ping["time"], sent: hash_ping["sent"].to_i, received: hash_ping["received"].to_i, packet_loss: hash_ping["packetLoss"].to_i ) end |
.parse_many(response) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/monogoto_api/ping.rb', line 17 def self.parse_many(response) output = [] response.each do |pre_ip| output.push(parse(pre_ip)) end output end |