Class: IPAddr

Inherits:
Object
  • Object
show all
Defined in:
lib/blather/core_ext/ipaddr.rb

Constant Summary collapse

PrivateRanges =
[
  IPAddr.new("10.0.0.0/8"),
  IPAddr.new("172.16.0.0/12"),
  IPAddr.new("192.168.0.0/16")
]

Instance Method Summary collapse

Instance Method Details

#private?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
# File 'lib/blather/core_ext/ipaddr.rb', line 9

def private?
  return false unless self.ipv4?
  PrivateRanges.each do |ipr|
    return true if ipr.include?(self)
  end
  return false
end

#public?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/blather/core_ext/ipaddr.rb', line 17

def public?
  !private?
end