Class: Dnsruby::RR::TXT

Inherits:
RR
  • Object
show all
Defined in:
lib/dnsruby/resource/TXT.rb

Overview

Class for DNS Text (TXT) resource records. RFC 1035 Section 3.3.14

Direct Known Subclasses

SPF

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::TXT
ESCAPE_CHARS =
{"b" => 8, "t" => 9, "n" => 10, "v" => 11, "f" => 12, "r" => 13}
ESCAPE_CODES =
ESCAPE_CHARS.invert

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stringsObject

List of the individual elements



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

def strings
  @strings
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



196
197
198
199
# File 'lib/dnsruby/resource/TXT.rb', line 196

def self.decode_rdata(msg) #:nodoc: all
  strings = msg.get_string_list
  return self.new(strings)
end

Instance Method Details

#dataObject



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

def data
  @strings.join
end

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



192
193
194
# File 'lib/dnsruby/resource/TXT.rb', line 192

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_string_list(@strings)
end

#from_data(data) ⇒ Object



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

def from_data(data)
  @strings = data
end

#from_hash(hash) ⇒ Object



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

def from_hash(hash)
  if (hash.has_key?:strings)
    from_string(hash[:strings])
  end
end

#from_string(input) ⇒ Object



48
49
50
# File 'lib/dnsruby/resource/TXT.rb', line 48

def from_string(input)
  @strings = TXT.parse(input)
end

#rdata_to_stringObject



180
181
182
183
184
185
186
187
188
189
190
# File 'lib/dnsruby/resource/TXT.rb', line 180

def rdata_to_string
  if (defined?@strings)
    temp = []
    @strings.each {|str|
      output = TXT.display(str)
      temp.push("\"#{output}\"")
    }
    return temp.join(' ')
  end
  return ''
end