Parent

Class Index [+]

Quicksearch

Dnsruby::Question

A Dnsruby::Question object represents a record in the question section of a DNS packet.

RFC 1035 Section 4.1.2

Attributes

qname[R]

The Question name

qtype[R]

The Question type

qclass[R]

The Question class

Public Class Methods

new(*args) 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.rb, line 1124
1124:     def initialize(*args)
1125:       @qtype = Types::A
1126:       @qclass = Classes::IN
1127:       if (args.length > 0)
1128:         if (args.length > 1)
1129:           @qtype = Types.new(args[1])
1130:           if (args.length > 2)
1131:             @qclass = Classes.new(args[2])
1132:           end
1133:         end
1134:       else
1135:         raise ArgumentError.new("Must pass at least a name!")
1136:       end
1137:       # If the name looks like an IP address then do an appropriate
1138:       # PTR query.
1139:       @qname=args[0]
1140:       case @qname.to_s
1141:       when IPv4::Regex
1142:         @qname = IPv4.create(@qname).to_name
1143:         @qtype = Types.PTR
1144:       when IPv6::Regex
1145:         @qname = IPv6.create(@qname).to_name
1146:         @qtype = Types.PTR
1147:       when Name
1148:       when IPv6
1149:         @qtype = Types.PTR
1150:       when IPv4
1151:         @qtype = Types.PTR
1152:       else
1153:         @qname = Name.create(@qname)
1154:       end
1155:     end

Public Instance Methods

qclass=(qclass) click to toggle source
      # File lib/Dnsruby/message.rb, line 1161
1161:     def qclass=(qclass)
1162:       @qclass = Classes.new(qclass)
1163:     end
qname=(qname) click to toggle source
      # File lib/Dnsruby/message.rb, line 1165
1165:     def qname=(qname)
1166:       case qname
1167:       when IPv4::Regex
1168:         @qname = IPv4.create(qname).to_name
1169:         @qtype = Types.PTR
1170:       when IPv6::Regex
1171:         @qname = IPv6.create(qname).to_name
1172:         @qtype = Types.PTR
1173:       when Name
1174:       when IPv6
1175:         @qtype = Types.PTR
1176:       when IPv4
1177:         @qtype = Types.PTR
1178:       else
1179:         @qname = Name.create(qname)
1180:       end
1181:     end
qtype=(qtype) click to toggle source
      # File lib/Dnsruby/message.rb, line 1157
1157:     def qtype=(qtype)
1158:       @qtype = Types.new(qtype)
1159:     end
to_s() click to toggle source

Returns a string representation of the question record.

      # File lib/Dnsruby/message.rb, line 1184
1184:     def to_s
1185:       return "#{@qname}.\t#{@qclass.string}\t#{@qtype.string}";
1186:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.