Class: IPAddr

Inherits:
Object
  • Object
show all
Defined in:
lib/std++/main.rb

Overview

Public Gem class IPAddr

Instance Method Summary collapse

Instance Method Details

#local?Boolean Also known as: private?

Returns true if given IP address is private(10.x.x.x||192.168.x.x||172.(16-31).x.x)

Returns:

  • (Boolean)


190
191
192
193
# File 'lib/std++/main.rb', line 190

def local?
  a, b = self.to_s.split('.')[0..1]
  return (a == '10') || (a == '192' && b == '168') || (a == '172' && (16..31) === b.to_i)
end