Class: Dnsruby::RR::DomainName

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

Overview

Abstract superclass for RR’s which have a domain name in the data section.

Direct Known Subclasses

CNAME, DNAME, MB, MG, MR, NS, PTR

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

#domainnameObject (readonly)

The domain name in the RR data section.



21
22
23
# File 'lib/dnsruby/resource/domain_name.rb', line 21

def domainname
  @domainname
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



51
52
53
54
55
56
57
# File 'lib/dnsruby/resource/domain_name.rb', line 51

def self.decode_rdata(msg) #:nodoc: all
  n = msg.get_name
  if n.length == 0
    # n = nil
  end
  self.new(n)
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



45
46
47
48
49
# File 'lib/dnsruby/resource/domain_name.rb', line 45

def encode_rdata(msg, canonical=false) #:nodoc: all
  if !([Classes::NONE, Classes::ANY].include? klass) || @rdata.length > 0
    msg.put_name(@domainname, canonical)
  end
end

#from_data(data) ⇒ Object

:nodoc: all



33
34
35
# File 'lib/dnsruby/resource/domain_name.rb', line 33

def from_data(data) #:nodoc: all
  @domainname = data
end

#from_hash(hash) ⇒ Object

:nodoc: all



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

def from_hash(hash) #:nodoc: all
  set_domain_name(hash[:domainname])
end

#from_string(input) ⇒ Object

:nodoc: all



37
38
39
# File 'lib/dnsruby/resource/domain_name.rb', line 37

def from_string(input) #:nodoc: all
  set_domain_name(input)
end

#rdata_to_stringObject

:nodoc: all



41
42
43
# File 'lib/dnsruby/resource/domain_name.rb', line 41

def rdata_to_string #:nodoc: all
  return @domainname.to_s(true)
end

#set_domain_name(newname) ⇒ Object Also known as: domainname=



23
24
25
# File 'lib/dnsruby/resource/domain_name.rb', line 23

def set_domain_name(newname)
  @domainname=Name.create(newname)
end