# Resolv::IPv4 (Class)

In: | resolv.rb
Parent: | Object

## Methods

== create eql? hash inspect new to_name to_s

## Constants

Regex | = | /\A(\d+)\.(\d+)\.(\d+)\.(\d+)\z/

## Attributes

address | [R] |

## Public Class methods

create(arg)

[Source]

    # File resolv.rb, line 1543
        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 interprete as IPv4 address: #{arg.inspect}")
          end
        end

new(address)

[Source]

    # File resolv.rb, line 1561
        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

to_s()

[Source]

    # File resolv.rb, line 1569
        def to_s
          return sprintf("%d.%d.%d.%d", *@address.unpack("CCCC"))
        end

inspect()

[Source]

    # File resolv.rb, line 1573
        def inspect
          return "#<#{self.class} #{self.to_s}>"
        end

to_name()

[Source]

    # File resolv.rb, line 1577
        def to_name
          return DNS::Name.create(
            '%d.%d.%d.%d.in-addr.arpa.' % @address.unpack('CCCC').reverse)
        end

==(other)

[Source]

    # File resolv.rb, line 1582
        def ==(other)
          return @address == other.address
        end

eql?(other)

[Source]

    # File resolv.rb, line 1586
        def eql?(other)
          return self == other
        end

hash()

[Source]

    # File resolv.rb, line 1590
        def hash
          return @address.hash
        end

[Validate]