Class: Dnsruby::RR::NAPTR

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

Overview

Class for DNS Naming Authority Pointer (NAPTR) resource records. RFC 2168

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::NAPTR

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

#flagsObject

The NAPTR RR flags field



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

def flags
  @flags
end

#orderObject

The NAPTR RR order field



25
26
27
# File 'lib/dnsruby/resource/NAPTR.rb', line 25

def order
  @order
end

#preferenceObject

The NAPTR RR preference field



27
28
29
# File 'lib/dnsruby/resource/NAPTR.rb', line 27

def preference
  @preference
end

#regexpObject

The NAPTR RR regexp field



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

def regexp
  @regexp
end

#replacementObject

The NAPTR RR replacement field



35
36
37
# File 'lib/dnsruby/resource/NAPTR.rb', line 35

def replacement
  @replacement
end

#serviceObject

The NAPTR RR service field



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

def service
  @service
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



89
90
91
92
93
94
95
96
97
# File 'lib/dnsruby/resource/NAPTR.rb', line 89

def self.decode_rdata(msg) #:nodoc: all
  order, = msg.get_unpack('n')
  preference, = msg.get_unpack('n')
  flags = msg.get_string
  service = msg.get_string
  regexp = msg.get_string
  replacement = msg.get_name
  return self.new([order, preference, flags, service, regexp, replacement])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



78
79
80
81
82
83
84
85
86
87
# File 'lib/dnsruby/resource/NAPTR.rb', line 78

def encode_rdata(msg, canonical=false) #:nodoc: all
  if (@order != nil)
    msg.put_pack('n', @order)
    msg.put_pack('n', @preference)
    msg.put_string(@flags)
    msg.put_string(@service)
    msg.put_string(@regexp)
    msg.put_name(@replacement, true)
  end
end

#from_data(data) ⇒ Object

:nodoc: all



46
47
48
# File 'lib/dnsruby/resource/NAPTR.rb', line 46

def from_data(data) #:nodoc: all
  @order,  @preference, @flags, @service, @regexp, @replacement = data
end

#from_hash(hash) ⇒ Object

:nodoc: all



37
38
39
40
41
42
43
44
# File 'lib/dnsruby/resource/NAPTR.rb', line 37

def from_hash(hash) #:nodoc: all
  @order = hash[:order]
  @preference = hash[:preference]
  @flags  = hash[:flags]
  @service = hash[:service]
  @regexp = hash[:regexp]
  @replacement = Name.create(hash[:replacement])
end

#from_string(input) ⇒ Object

:nodoc: all



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/dnsruby/resource/NAPTR.rb', line 54

def from_string(input) #:nodoc: all
  if (input.strip.length > 0)
    values = input.split(" ")
    @order = values [0].to_i
    @preference = values [1].to_i
    @flags = values [2].gsub!("\"", "")
    @service = values [3].gsub!("\"", "")
    @regexp = TXT.parse(values[4])[0]
    @replacement = Name.create(values[5])
  end
end

#rdata_to_stringObject

:nodoc: all



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/dnsruby/resource/NAPTR.rb', line 66

def rdata_to_string #:nodoc: all
  if (@order!=nil)
    ret =  "#{@order} #{@preference} \"#{@flags}\" \"#{@service}\" \""
    ret += TXT.display(@regexp)
    ret += "\" #{@replacement.to_s(true)}"

    return ret
  else
    return ""
  end
end