Class: Dnsruby::RR::URI

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

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::URI

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

#priorityObject

The NAPTR RR order field



8
9
10
# File 'lib/dnsruby/resource/URI.rb', line 8

def priority
  @priority
end

#targetObject

The NAPTR RR order field



14
15
16
# File 'lib/dnsruby/resource/URI.rb', line 14

def target
  @target
end

#weightObject

The NAPTR RR order field



11
12
13
# File 'lib/dnsruby/resource/URI.rb', line 11

def weight
  @weight
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



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

def self.decode_rdata(msg) #:nodoc: all
  priority, = msg.get_unpack('n')
  weight, = msg.get_unpack('n')
  target = msg.get_bytes
  return self.new([priority, weight, target])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



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

def encode_rdata(msg, canonical=false) #:nodoc: all
  if (@priority != nil)
    msg.put_pack('n', @priority)
    msg.put_pack('n', @weight)
    msg.put_bytes(@target)
  end
end

#from_data(data) ⇒ Object

:nodoc: all



22
23
24
# File 'lib/dnsruby/resource/URI.rb', line 22

def from_data(data) #:nodoc: all
  @priority,  @weight, @target = data
end

#from_hash(hash) ⇒ Object

:nodoc: all



16
17
18
19
20
# File 'lib/dnsruby/resource/URI.rb', line 16

def from_hash(hash) #:nodoc: all
  @priority = hash[:priority]
  @weight = hash[:weight]
  @target = hash[:target]
end

#from_string(input) ⇒ Object

:nodoc: all



26
27
28
29
30
31
32
33
# File 'lib/dnsruby/resource/URI.rb', line 26

def from_string(input) #:nodoc: all
  if (input.strip.length > 0)
    values = input.split(" ")
    @priority = values [0].to_i
    @weight = values [1].to_i
    @target = values [2].gsub!("\"", "")
  end
end

#rdata_to_stringObject

:nodoc: all



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

def rdata_to_string #:nodoc: all
    "#{@priority} #{@weight} \"#{@target}\""
end