Class: Dnsruby::RR::IN::AFSDB

Inherits:
Dnsruby::RR show all
Defined in:
lib/dnsruby/resource/AFSDB.rb

Overview

Class for DNS AFS Data Base (AFSDB) resource records.

RFC 1183 Section 1

Constant Summary

Constants inherited from Dnsruby::RR

ClassInsensitiveTypes

Instance Attribute Summary collapse

Attributes inherited from Dnsruby::RR

#klass, #name, #rdata, #ttl, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dnsruby::RR

#<=>, #==, #clone, create, #eql?, find_class, get_class, get_num, #hash, implemented_rrs, #init_defaults, new_from_data, new_from_hash, new_from_string, #rdlength, #sameRRset, #to_s

Instance Attribute Details

#hostnameObject

The RR’s hostname field. See RFC 1183.



29
30
31
# File 'lib/dnsruby/resource/AFSDB.rb', line 29

def hostname
  @hostname
end

#subtypeObject

The RR’s subtype field. See RFC 1183.



26
27
28
# File 'lib/dnsruby/resource/AFSDB.rb', line 26

def subtype
  @subtype
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



60
61
62
63
64
# File 'lib/dnsruby/resource/AFSDB.rb', line 60

def self.decode_rdata(msg) #:nodoc: all
  subtype,     = msg.get_unpack("n")
  hostname    = msg.get_name
  return self.new([subtype, hostname])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



55
56
57
58
# File 'lib/dnsruby/resource/AFSDB.rb', line 55

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_pack("n", @subtype.to_i)
  msg.put_name(@hostname, canonical)
end

#from_data(data) ⇒ Object

:nodoc: all



36
37
38
# File 'lib/dnsruby/resource/AFSDB.rb', line 36

def from_data(data) #:nodoc: all
  @subtype, @hostname = data
end

#from_hash(hash) ⇒ Object

:nodoc: all



31
32
33
34
# File 'lib/dnsruby/resource/AFSDB.rb', line 31

def from_hash(hash) #:nodoc: all
  @subtype = hash[:subtype]
  @hostname = Name.create(hash[:hostname])
end

#from_string(input) ⇒ Object

:nodoc: all



40
41
42
43
44
45
# File 'lib/dnsruby/resource/AFSDB.rb', line 40

def from_string(input) #:nodoc: all
  if (input!=nil && (input =~ /^(\d+)\s+(\S+)$/o))
    @subtype  = $1;
    @hostname = Name.create($2)
  end
end

#rdata_to_stringObject

:nodoc: all



47
48
49
50
51
52
53
# File 'lib/dnsruby/resource/AFSDB.rb', line 47

def rdata_to_string #:nodoc: all
  if defined?@subtype
    return "#{@subtype} #{@hostname.to_s(true)}"
  else
    return '';
  end
end