class Avalon::Internet
Internet
is a node encapsulating information about Internet
connectivity
Constants
- IP_REGEXP
Public Class Methods
new(monitor, *sites)
click to toggle source
Calls superclass method
# File lib/avalon/internet.rb, line 8 def initialize monitor, *sites sites.map! do |site| name = site =~ IP_REGEXP ? site : site.split(/\./)[-2] [name.to_sym, site] end @sites = Hash[ *sites.flatten ] super() end
Public Instance Methods
poll(verbose=true)
click to toggle source
# File lib/avalon/internet.rb, line 17 def poll verbose=true @sites.each {|name, site| self[name] = ping site } puts "#{self}" if verbose end
report()
click to toggle source
Check for any exceptional situations with Node
, sound alarm if any
# File lib/avalon/internet.rb, line 23 def report @data.each do |target, ping| alarm "Ping #{target} failed, check your Internet connection" unless ping end end
to_s()
click to toggle source
# File lib/avalon/internet.rb, line 29 def to_s "Internet: " + @data.map {|name, value| "#{name}:#{value}"}.join(" ") end