Class: Resolv::IPv4 (Ruby 2.4.2)
Description: Class : Resolv::IPv4 - Ruby 2.4.2

Support for the Ruby 2.4 series has ended. See here for reference.

### Home Classes Methods

### In Files

- resolv.rb

### Parent

Object

### Methods

- ::create
- #to_name

### Class/Module Index

Quicksearch

- Resolv
- Resolv::DNS
- Resolv::DNS::Config
- Resolv::DNS::Config::NXDomain
- Resolv::DNS::Config::OtherResolvError
- Resolv::DNS::DecodeError
- Resolv::DNS::EncodeError
- Resolv::DNS::Name
- Resolv::DNS::Query
- Resolv::DNS::Requester
- Resolv::DNS::Requester::RequestError
- Resolv::DNS::Resource
- Resolv::DNS::Resource::ANY
- Resolv::DNS::Resource::CNAME
- Resolv::DNS::Resource::DomainName
- Resolv::DNS::Resource::Generic
- Resolv::DNS::Resource::HINFO
- Resolv::DNS::Resource::IN
- Resolv::DNS::Resource::IN::A
- Resolv::DNS::Resource::IN::AAAA
- Resolv::DNS::Resource::IN::SRV
- Resolv::DNS::Resource::IN::WKS
- Resolv::DNS::Resource::LOC
- Resolv::DNS::Resource::MINFO
- Resolv::DNS::Resource::MX
- Resolv::DNS::Resource::NS
- Resolv::DNS::Resource::PTR
- Resolv::DNS::Resource::SOA
- Resolv::DNS::Resource::TXT
- Resolv::Hosts
- Resolv::IPv4
- Resolv::IPv6
- Resolv::LOC
- Resolv::LOC::Alt
- Resolv::LOC::Coord
- Resolv::LOC::Size
- Resolv::MDNS
- Resolv::ResolvError
- Resolv::ResolvTimeout

No matching classes.

# Resolv::IPv4

A `Resolv::DNS` `IPv4` address.

### Constants

Regex
Regex256

  Regular expression `IPv4` addresses must match.

### Attributes

address[R]

The raw `IPv4` address as a String.

### Public Class Methods

create(arg) click to toggle source

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

### Public Instance Methods

to_name() click to toggle source

Turns this `IPv4` address into a `Resolv::DNS::Name`.

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