Class: Dnsruby::Question

### Home Classes Methods

### In Files

- lib/dnsruby/message/question.rb

### Parent

Object

### Methods

- ::new
- #==
- #qclass=
- #qname=
- #qtype=
- #set_qname
- #to_s

### Files

- DNSSEC
- EVENTMACHINE
- EXAMPLES

### Class/Module Index

Quicksearch

- Dnsruby
- Dnsruby::Algorithms
- Dnsruby::BitMapping
- Dnsruby::Bitmap
- Dnsruby::Classes
- Dnsruby::CodeMapper
- Dnsruby::Config
- Dnsruby::DNS
- Dnsruby::DecodeError
- Dnsruby::Dnssec
- Dnsruby::Dnssec::ValidationPolicy
- Dnsruby::EncodeError
- Dnsruby::ExtendedRCode
- Dnsruby::FormErr
- Dnsruby::Header
- Dnsruby::Hosts
- Dnsruby::IPv4
- Dnsruby::IPv6
- Dnsruby::Message
- Dnsruby::Message::SecurityLevel
- Dnsruby::MetaTypes
- Dnsruby::Modes
- Dnsruby::NXDomain
- Dnsruby::NXRRSet
- Dnsruby::Name
- Dnsruby::Name::Label
- Dnsruby::NotAuth
- Dnsruby::NotImp
- Dnsruby::NotZone
- Dnsruby::Nsec3HashAlgorithms
- Dnsruby::OpCode
- Dnsruby::OtherResolvError
- Dnsruby::QTypes
- Dnsruby::Question
- Dnsruby::RCode
- Dnsruby::RR
- Dnsruby::RR::ANY
- Dnsruby::RR::CERT
- Dnsruby::RR::CERT::CertificateTypes
- Dnsruby::RR::CNAME
- Dnsruby::RR::DHCID
- Dnsruby::RR::DLV
- Dnsruby::RR::DNAME
- Dnsruby::RR::DNSKEY
- Dnsruby::RR::DS
- Dnsruby::RR::DS::DigestTypes
- Dnsruby::RR::DomainName
- Dnsruby::RR::GPOS
- Dnsruby::RR::Generic
- Dnsruby::RR::HINFO
- Dnsruby::RR::HIP
- Dnsruby::RR::IN
- Dnsruby::RR::IN::A
- Dnsruby::RR::IN::AAAA
- Dnsruby::RR::IN::AFSDB
- Dnsruby::RR::IN::PX
- Dnsruby::RR::IN::SRV
- Dnsruby::RR::IN::WKS
- Dnsruby::RR::IPSECKEY
- Dnsruby::RR::ISDN
- Dnsruby::RR::KX
- Dnsruby::RR::LOC
- Dnsruby::RR::MB
- Dnsruby::RR::MG
- Dnsruby::RR::MINFO
- Dnsruby::RR::MR
- Dnsruby::RR::MX
- Dnsruby::RR::NAPTR
- Dnsruby::RR::NS
- Dnsruby::RR::NSAP
- Dnsruby::RR::NSEC
- Dnsruby::RR::NSEC3
- Dnsruby::RR::NSEC3PARAM
- Dnsruby::RR::NXT
- Dnsruby::RR::NXT::NxtTypes
- Dnsruby::RR::NXT::TypeBitmap
- Dnsruby::RR::OPT
- Dnsruby::RR::PTR
- Dnsruby::RR::RP
- Dnsruby::RR::RRSIG
- Dnsruby::RR::RT
- Dnsruby::RR::SOA
- Dnsruby::RR::SPF
- Dnsruby::RR::SSHFP
- Dnsruby::RR::SSHFP::Algorithms
- Dnsruby::RR::SSHFP::FpTypes
- Dnsruby::RR::TKEY
- Dnsruby::RR::TSIG
- Dnsruby::RR::TXT
- Dnsruby::RR::X25
- Dnsruby::RRSet
- Dnsruby::Recursor
- Dnsruby::Refused
- Dnsruby::Resolv
- Dnsruby::ResolvError
- Dnsruby::ResolvTimeout
- Dnsruby::Resolver
- Dnsruby::Resolver::EventType
- Dnsruby::Section
- Dnsruby::SelectThread
- Dnsruby::ServFail
- Dnsruby::SingleResolver
- Dnsruby::SocketEofResolvError
- Dnsruby::TheLog
- Dnsruby::TsigError
- Dnsruby::TsigNotSignedResponseError
- Dnsruby::Types
- Dnsruby::Update
- Dnsruby::VerifyError
- Dnsruby::YXDomain
- Dnsruby::YXRRSet
- Dnsruby::ZoneReader
- Dnsruby::ZoneReader::ParseException
- Dnsruby::ZoneSerialError
- Dnsruby::ZoneTransfer
- Dnsruby::ZoneTransfer::Delta
- Base32
- Object

No matching classes.

# Dnsruby::Question

### Attributes

qclass[R]

The Question class

qname[R]

The Question name

qtype[R]

The Question type

type[R]

The Question type

zclass[R]

The Question class

zname[R]

The Question name

ztype[R]

The Question type

### Public Class Methods

new(qname, qtype = :not_provided, qclass = :not_provided) click to toggle source

Creates a question object from the domain, type, and class passed as arguments.

If a String is passed in, a Name, IPv4 or IPv6 object is created.

If an IPv4 or IPv6 object is used then the type is set to PTR.

    # File lib/dnsruby/message/question.rb, line 21
    def initialize(qname, qtype = :not_provided, qclass = :not_provided)

      raise ArgumentError.new('qname must not be nil') if qname.nil?

      @qtype  = (qtype  == :not_provided) ? Types::A    : Types.new(qtype)
      @qclass = (qclass == :not_provided) ? Classes::IN : Classes.new(qclass)
      set_qname(qname, qtype == :not_provided)
    end

### Public Instance Methods

==(other) click to toggle source

    # File lib/dnsruby/message/question.rb, line 65
    def ==(other)
      other.is_a?(Question) &&
          self.qname  == other.qname  &&
          self.qtype  == other.qtype  &&
          self.qclass == other.qclass
    end

qclass=(qclass) click to toggle source

    # File lib/dnsruby/message/question.rb, line 34
    def qclass=(qclass)
      @qclass = Classes.new(qclass)
    end

qname=(qname) click to toggle source

    # File lib/dnsruby/message/question.rb, line 61
    def qname=(qname)
      set_qname(qname, true)
    end

qtype=(qtype) click to toggle source

    # File lib/dnsruby/message/question.rb, line 30
    def qtype=(qtype)
      @qtype = Types.new(qtype)
    end

set_qname(qname, write_PTR_to_qtype_if_ip = true) click to toggle source

    # File lib/dnsruby/message/question.rb, line 38
    def set_qname(qname, write_PTR_to_qtype_if_ip = true)
      is_ipv4_addr_string = qname.is_a?(String) && IPv4::Regex.match(qname)
      is_ipv6_addr_string = qname.is_a?(String) && IPv6::Regex.match(qname)
      is_ip_addr_string = is_ipv4_addr_string || is_ipv6_addr_string

      is_ip_addr = [IPv4, IPv6].any? { |klass| qname.is_a?(klass) }

      if is_ipv4_addr_string
        @qname = IPv4.create(qname).to_name
      elsif is_ipv6_addr_string
        @qname = IPv6.create(qname).to_name
      else
        @qname = Name.create(qname)
      end

      #  If the name looks like an IP address then do an appropriate
      #  PTR query, unless the user specified the qtype
      if write_PTR_to_qtype_if_ip && (is_ip_addr || is_ip_addr_string)
        @qtype = Types.PTR
      end
      @qname.absolute = true
    end

to_s() click to toggle source

Returns a string representation of the question record.

    # File lib/dnsruby/message/question.rb, line 73
    def to_s
      "#{@qname}.\t#{@qclass.string}\t#{@qtype.string}"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.