Class: Dnsruby::RR::TXT
- Inherits:
-
Dnsruby::RR
- Object
- Dnsruby::RR
- Dnsruby::RR::TXT
- Defined in:
- lib/Dnsruby/resource/TXT.rb
Overview
Class for DNS Text (TXT) resource records. RFC 1035 Section 3.3.14
Direct Known Subclasses
Constant Summary collapse
Constants inherited from Dnsruby::RR
Instance Attribute Summary collapse
-
#strings ⇒ Object
List of the individual elements.
Attributes inherited from Dnsruby::RR
#klass, #name, #rdata, #ttl, #type
Class Method Summary collapse
-
.decode_rdata(msg) ⇒ Object
:nodoc: all.
Instance Method Summary collapse
- #data ⇒ Object
-
#encode_rdata(msg) ⇒ Object
:nodoc: all.
- #from_data(data) ⇒ Object
- #from_hash(hash) ⇒ Object
- #from_string(input) ⇒ Object
- #rdata_to_string ⇒ Object
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
#strings ⇒ Object
List of the individual elements
26 27 28 |
# File 'lib/Dnsruby/resource/TXT.rb', line 26 def strings @strings end |
Class Method Details
.decode_rdata(msg) ⇒ Object
:nodoc: all
70 71 72 73 |
# File 'lib/Dnsruby/resource/TXT.rb', line 70 def self.decode_rdata(msg) #:nodoc: all strings = msg.get_string_list return self.new(strings) end |
Instance Method Details
#data ⇒ Object
28 29 30 |
# File 'lib/Dnsruby/resource/TXT.rb', line 28 def data @strings[0] end |
#encode_rdata(msg) ⇒ Object
:nodoc: all
66 67 68 |
# File 'lib/Dnsruby/resource/TXT.rb', line 66 def encode_rdata(msg) #:nodoc: all msg.put_string_list(@strings) end |
#from_data(data) ⇒ Object
32 33 34 |
# File 'lib/Dnsruby/resource/TXT.rb', line 32 def from_data(data) @strings = data end |
#from_hash(hash) ⇒ Object
36 37 38 39 40 |
# File 'lib/Dnsruby/resource/TXT.rb', line 36 def from_hash(hash) if (hash.has_key?:strings) from_string(hash[:strings]) end end |
#from_string(input) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/Dnsruby/resource/TXT.rb', line 42 def from_string(input) words = Shellwords.shellwords(input) @strings=[] if (words != nil) words.each { |string| string .gsub!(/\\"/, '"') @strings.push(string) } end end |
#rdata_to_string ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/Dnsruby/resource/TXT.rb', line 55 def rdata_to_string if (defined?@strings) temp = @strings.map {|str| str.gsub(/"/, '\\"') %<"#{str}"> } return temp.join(' ') end return '' end |