class Pingfacts::PingerResult
Attributes
dnsname[RW]
ip[RW]
mac[RW]
Public Class Methods
configs()
click to toggle source
# File lib/pingfacts.rb, line 30 def self.configs @@configs end
configs=(new_value)
click to toggle source
# File lib/pingfacts.rb, line 34 def self.configs=(new_value) @@configs = new_value end
strictmode()
click to toggle source
# File lib/pingfacts.rb, line 22 def self.strictmode @@strictmode end
strictmode=(new_value)
click to toggle source
# File lib/pingfacts.rb, line 26 def self.strictmode=(new_value) @@strictmode = new_value end
Public Instance Methods
eql?(other)
click to toggle source
# File lib/pingfacts.rb, line 76 def eql?(other) if @@strictmode return (self.ip == other.ip and self.mac == other.mac and self.dnsname == other.dnsname) end result = false if self.mac != nil and other.mac != nil if self.mac == other.mac result = true end end if self.dnsname != nil and other.dnsname != nil if self.dnsname == other.dnsname return true end end if self.ip != nil and other.ip != nil if self.ip == other.ip result = true end end return result end
path_vendorlist()
click to toggle source
# File lib/pingfacts.rb, line 38 def path_vendorlist "#{@@configs}/vendorlist" end
prepare_configs()
click to toggle source
# File lib/pingfacts.rb, line 42 def prepare_configs begin Dir.mkdir(@@configs) rescue Errno::EEXIST end vendor_content = nil unless File.exist? path_vendorlist vendor_content = URI.open("http://standards-oui.ieee.org/oui/oui.txt").read open(path_vendorlist, "w") do |file| file << vendor_content end else if @@vendors.nil? open(path_vendorlist, "r") do |file| vendor_content = file.read end end end if @@vendors.nil? and (not vendor_content.nil?) @@vendors = {} vendor_content.lines.each do |line| if (/\(base\s+16\)/i).match(line) result = (/^([0-9A-F]+)\s+\(base\s+16\)\s+(.+)$/i).match(line) unless result.nil? @@vendors[result[1]] = result[2] end end end end end
vendor()
click to toggle source
# File lib/pingfacts.rb, line 100 def vendor if self.mac.nil? return nil end self.prepare_configs teststring = self.mac.upcase.gsub /[^0-9A-F]*/i, "" result = @@vendors[teststring[0,6]] if result.nil? return nil end return result.strip end