Class: MtrMonitor::Hop

Inherits:
Object
  • Object
show all
Defined in:
lib/mtr_monitor/hop.rb

Overview

represents one hop in the MTR report

example hop for ‘mtr –report github.com`: 12.|– github-ic-318125-ash-b1.c 0.0% 10 136.2 136.2 135.0 140.7 1.5

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, loss, snt, last, avg, best, worst, std_dev) ⇒ Hop

Returns a new instance of Hop.



17
18
19
20
21
22
23
24
25
26
# File 'lib/mtr_monitor/hop.rb', line 17

def initialize(name, loss, snt, last, avg, best, worst, std_dev)
  @name    = name
  @loss    = loss.to_f
  @snt     = snt.to_i
  @last    = last.to_f
  @avg     = avg.to_f
  @best    = best.to_f
  @worst   = worst.to_f
  @std_dev = std_dev.to_f
end

Instance Attribute Details

#avgObject (readonly)

Returns the value of attribute avg.



15
16
17
# File 'lib/mtr_monitor/hop.rb', line 15

def avg
  @avg
end

#bestObject (readonly)

Returns the value of attribute best.



15
16
17
# File 'lib/mtr_monitor/hop.rb', line 15

def best
  @best
end

#lastObject (readonly)

Returns the value of attribute last.



15
16
17
# File 'lib/mtr_monitor/hop.rb', line 15

def last
  @last
end

#lossObject (readonly)

Returns the value of attribute loss.



15
16
17
# File 'lib/mtr_monitor/hop.rb', line 15

def loss
  @loss
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/mtr_monitor/hop.rb', line 15

def name
  @name
end

#sntObject (readonly)

Returns the value of attribute snt.



15
16
17
# File 'lib/mtr_monitor/hop.rb', line 15

def snt
  @snt
end

#std_devObject (readonly)

Returns the value of attribute std_dev.



15
16
17
# File 'lib/mtr_monitor/hop.rb', line 15

def std_dev
  @std_dev
end

#worstObject (readonly)

Returns the value of attribute worst.



15
16
17
# File 'lib/mtr_monitor/hop.rb', line 15

def worst
  @worst
end

Class Method Details

.parse(line) ⇒ Object



9
10
11
12
13
# File 'lib/mtr_monitor/hop.rb', line 9

def self.parse(line)
  return unless line =~ /\|--/

  new(*line.split(" ")[1..-1])
end