class Net::DNS::RR::TXT

Attributes

txt[R]

Private Instance Methods

build_pack() click to toggle source
# File lib/net/dns/rr/txt.rb, line 13
def build_pack
  str = ""
  @txt.split(" ").each do |txt|
    str += [txt.length,txt].pack("C a*")
  end
  @txt_pack = str
  @rdlength = @txt_pack.size
end
get_data() click to toggle source
# File lib/net/dns/rr/txt.rb, line 26
def get_data
  @txt_pack
end
get_inspect() click to toggle source
# File lib/net/dns/rr/txt.rb, line 22
def get_inspect
  "\"#{@txt}\""
end
set_type() click to toggle source
# File lib/net/dns/rr/txt.rb, line 63
def set_type
  @type = Net::DNS::RR::Types.new("TXT")
end
subclass_new_from_binary(data,offset) click to toggle source
# File lib/net/dns/rr/txt.rb, line 47
def subclass_new_from_binary(data,offset)
  off_end = offset + @rdlength
  rs = []
  while offset < off_end
    len = data.unpack("@#{offset} C")[0]
    offset += 1
    str = data[offset..offset+len-1]
    offset += len
    rs << str
  end
  @txt = rs.join(" ")
  return offset
end
subclass_new_from_hash(args) click to toggle source
# File lib/net/dns/rr/txt.rb, line 30
def subclass_new_from_hash(args)
  if args.has_key? :txt
    @txt = args[:txt].strip
  else
    raise ArgumentError, ":txt field is mandatory but missing"
  end
end
subclass_new_from_string(str) click to toggle source
# File lib/net/dns/rr/txt.rb, line 38
def subclass_new_from_string(str)
  @txt = str.strip
  if @txt[0] == '"' and @txt[-1] == '"'
    @txt = @txt[1, @txt.length-2]
  else
    raise ArgumentError, "TXT RR data must be enclosed in \"quotes\""
  end
end