class IpAddress

Public Class Methods

from_dotted(str) click to toggle source
# File lib/gorillib/type/ip_address.rb, line 63
def self.from_dotted(str)
  new(str)
end
from_packed(pi) click to toggle source

class methods ===

# File lib/gorillib/type/ip_address.rb, line 58
def self.from_packed(pi)
  str = [ (pi >> 24) & 0xFF, (pi >> 16) & 0xFF, (pi >>  8) & 0xFF, (pi) & 0xFF ].join(".")
  new(str)
end

Public Instance Methods

dotted() click to toggle source
# File lib/gorillib/type/ip_address.rb, line 38
def dotted
  self
end
packed() click to toggle source

@returns [Integer] the 32-bit integer for this IP address

# File lib/gorillib/type/ip_address.rb, line 47
def packed
  ip_a, ip_b, ip_c, ip_d = quads
  ((ip_a << 24) + (ip_b << 16) + (ip_c << 8) + (ip_d))
end
quads() click to toggle source
# File lib/gorillib/type/ip_address.rb, line 52
def quads
  self.split(".", 4).map{|qq| Integer(qq) }
end
to_i() click to toggle source
# File lib/gorillib/type/ip_address.rb, line 42
def to_i
  packed
end