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

#==, create, #eql?, get_class, #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



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

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



70
71
72
73
74
75
76
77
# File 'lib/Dnsruby/resource/NAPTR.rb', line 70

def encode_rdata(msg, canonical=false) #:nodoc: all
  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, canonical)
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



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/Dnsruby/resource/NAPTR.rb', line 50

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

#rdata_to_stringObject

:nodoc: all



62
63
64
65
66
67
68
# File 'lib/Dnsruby/resource/NAPTR.rb', line 62

def rdata_to_string #:nodoc: all
  if (@order!=nil)
    return "#{@order} #{@preference} #{@flags} #{@service} #{@regexp} #{@replacement}"
  else
    return ""
  end
end