class Tr8n::IpAddress

Public Class Methods

non_routable?(ip) click to toggle source
# File lib/tr8n/ip_address.rb, line 40
def self.non_routable?(ip)
  return true if ip.blank?
  ip = new(ip.to_s) unless ip.is_a?(Tr8n::IpAddress)
  ip.non_routable?
rescue ArgumentError
  return true
end
non_routable_networks() click to toggle source
# File lib/tr8n/ip_address.rb, line 27
def self.non_routable_networks
  @non_routable_networks ||= [
    Tr8n::IpAddress.new('10.0.0.0/8'),
    Tr8n::IpAddress.new('127.0.0.0/8'),
    Tr8n::IpAddress.new('172.16.0.0/12'),
    Tr8n::IpAddress.new('192.168.0.0/16'),
  ]
end
routable?(ip) click to toggle source
# File lib/tr8n/ip_address.rb, line 36
def self.routable?(ip)
  not non_routable?(ip)
end

Public Instance Methods

non_routable?() click to toggle source
# File lib/tr8n/ip_address.rb, line 48
def non_routable?
  self.class.non_routable_networks.each {|network| return true if network.include?(self)}
  false
end