class Ytstat::Host

Attributes

avg[RW]
max[RW]
min[RW]
stddev[RW]
url[RW]

Public Class Methods

new(name, domain='vpndidu.com') click to toggle source
# File lib/ytstat/host.rb, line 5
def initialize(name, domain='vpndidu.com')
  @url = [name, domain].join('.')
  @min = @max = @avg = @stddev = Float::MAX
end

Public Instance Methods

ping() click to toggle source
# File lib/ytstat/host.rb, line 10
def ping
  s = `ping -q -c 3 #{@url}`
  s.lines[-1] =~ /= (.*) ms/
    @min, @avg, @max, @stddev = $1.split('/').map {|x| x.to_f } if $1
end