lib/net/dns/rr/ptr.rb in net-dns-0.6.1 vs lib/net/dns/rr/ptr.rb in net-dns-0.7.0

- old
+ new

@@ -1,9 +1,9 @@ module Net module DNS class RR - + # # = Pointer Record (PTR) # # Class for DNS Pointer (PTR) resource records. # @@ -11,60 +11,73 @@ # and are used in Reverse Map zone files to map # an IP address (IPv4 or IPv6) to a host name. # class PTR < RR - # Getter for PTR resource - def ptr + # Gets the PTR value. + # + # Returns a String. + def ptrdname @ptrdname.to_s end - alias_method :ptrdname, :ptr - - private - - def check_ptr(str) - IPAddr.new str - rescue - raise ArgumentError, "PTR section not valid" + + alias_method :ptr, :ptrdname + + # Gets the standardized value for this record, + # represented by the value of <tt>ptrdname</tt>. + # + # Returns a String. + def value + ptrdname.to_s end - + + + private + def build_pack @ptrdname_pack = pack_name(@ptrdname) @rdlength = @ptrdname_pack.size end def get_data @ptrdname_pack end - def get_inspect - "#@ptrdname" - end - def subclass_new_from_hash(args) - if args.has_key? :ptrdname or args.has_key? :ptr - @ptrdname = args[0][:ptrdname] + if args.has_key?(:ptrdname) or args.has_key?(:ptr) + @ptrdname = args[:ptrdname] else - raise ArgumentError, ":ptrdname or :ptr field is mandatory but missing" + raise ArgumentError, ":ptrdname or :ptr field is mandatory" end end def subclass_new_from_string(str) - @ptrdname = check_ptr(str) + @ptrdname = check_name(str) end - def subclass_new_from_binary(data,offset) - @ptrdname,offset = dn_expand(data,offset) - return offset + def subclass_new_from_binary(data, offset) + @ptrdname, offset = dn_expand(data, offset) + offset end - + private - - def set_type - @type = Net::DNS::RR::Types.new("PTR") - end - - end # class PTR - - end # class RR - end # module DNS -end # module Net + + def set_type + @type = Net::DNS::RR::Types.new("PTR") + end + + def get_inspect + value + end + + + def check_name(input) + IPAddr.new(str) + rescue + raise ArgumentError, "Invalid PTR Section `#{input}'" + end + + end + + end + end +end