Class: Dnsruby::RR::KX

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

Overview

Class for DNS Key Exchange (KX) resource records. RFC 2230

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::KX

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

#exchangeObject

The name of this mail exchange.



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

def exchange
  @exchange
end

#preferenceObject

The preference for this mail exchange.



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

def preference
  @preference
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



59
60
61
62
63
# File 'lib/dnsruby/resource/KX.rb', line 59

def self.decode_rdata(msg) #:nodoc: all
  preference, = msg.get_unpack('n')
  exchange = msg.get_name
  return self.new([preference, exchange])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



54
55
56
57
# File 'lib/dnsruby/resource/KX.rb', line 54

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_pack('n', @preference)
  msg.put_name(@exchange, true)
end

#from_data(data) ⇒ Object

:nodoc: all



34
35
36
# File 'lib/dnsruby/resource/KX.rb', line 34

def from_data(data) #:nodoc: all
  @preference, @exchange = data
end

#from_hash(hash) ⇒ Object

:nodoc: all



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

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

#from_string(input) ⇒ Object

:nodoc: all



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

def from_string(input) #:nodoc: all
  if (input.length > 0)
    names = input.split(" ")
    @preference = names[0].to_i
    @exchange = Name.create(names[1])
  end
end

#rdata_to_stringObject

:nodoc: all



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

def rdata_to_string #:nodoc: all
  if (@preference!=nil)
    return "#{@preference} #{@exchange.to_s(true)}"
  else
    return ""
  end
end