In Files

  • resolv.rb

Resolv::IPv4

Constants

Regex

Attributes

address[R]

Public Class Methods

create(arg) click to toggle source
 
               # File resolv.rb, line 1763
def self.create(arg)
  case arg
  when IPv4
    return arg
  when Regex
    if (0..255) === (a = $1.to_i) &&
       (0..255) === (b = $2.to_i) &&
       (0..255) === (c = $3.to_i) &&
       (0..255) === (d = $4.to_i)
      return self.new([a, b, c, d].pack("CCCC"))
    else
      raise ArgumentError.new("IPv4 address with invalid value: " + arg)
    end
  else
    raise ArgumentError.new("cannot interpret as IPv4 address: #{arg.inspect}")
  end
end
            
new(address) click to toggle source
 
               # File resolv.rb, line 1781
def initialize(address)
  unless address.kind_of?(String) && address.length == 4
    raise ArgumentError.new('IPv4 address must be 4 bytes')
  end
  @address = address
end
            

Public Instance Methods

==(other) click to toggle source
 
               # File resolv.rb, line 1802
def ==(other)
  return @address == other.address
end
            
eql?(other) click to toggle source
 
               # File resolv.rb, line 1806
def eql?(other)
  return self == other
end
            
hash() click to toggle source
 
               # File resolv.rb, line 1810
def hash
  return @address.hash
end
            
inspect() click to toggle source
 
               # File resolv.rb, line 1793
def inspect
  return "#<#{self.class} #{self.to_s}>"
end
            
to_name() click to toggle source
 
               # File resolv.rb, line 1797
def to_name
  return DNS::Name.create(
    '%d.%d.%d.%d.in-addr.arpa.' % @address.unpack('CCCC').reverse)
end
            
to_s() click to toggle source
 
               # File resolv.rb, line 1789
def to_s
  return sprintf("%d.%d.%d.%d", *@address.unpack("CCCC"))
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus