Class: Resolv::DNS::Resource::TXT
- Inherits:
-
Resolv::DNS::Resource
- Object
- Query
- Resolv::DNS::Resource
- Resolv::DNS::Resource::TXT
- Defined in:
- lib/net/dns/resolv.rb
Constant Summary collapse
- TypeValue =
16
Constants inherited from Resolv::DNS::Resource
ClassHash, ClassInsensitiveTypes, ClassValue
Instance Attribute Summary collapse
-
#strings ⇒ Object
readonly
Returns an array of all the strings making up the resource data.
Class Method Summary collapse
-
.decode_rdata(msg) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#data ⇒ Object
Returns the resource data as a single string.
-
#encode_rdata(msg) ⇒ Object
:nodoc:.
-
#initialize(first_string = '', *rest_strings) ⇒ TXT
constructor
TXT resource records must have one or more character strings, but the string may be zero-length.
Methods inherited from Resolv::DNS::Resource
Constructor Details
#initialize(first_string = '', *rest_strings) ⇒ TXT
TXT resource records must have one or more character strings, but the string may be zero-length.
If only the first_string
is supplied, it may be longer than 255 characters (internally, it will split into multiple character-strings). If multiple strings are supplied, each string must not be longer than 255 characters.
1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 |
# File 'lib/net/dns/resolv.rb', line 1661 def initialize(first_string = '', *rest_strings) if first_string.length > 255 raise ArgumentError, 'TXT strings are longer than 255 characters' if rest_strings.first @strings = [] first_string.scan(/.{1,255}/) { |s| @strings << s } else @strings = [first_string, *rest_strings].compact end end |
Instance Attribute Details
#strings ⇒ Object (readonly)
Returns an array of all the strings making up the resource data. There may be multiple strings if this is a mDNS record or if the resource data is longer than 255 bytes. In the case of mDNS, each individual string has the form: “key=value”.
1676 1677 1678 |
# File 'lib/net/dns/resolv.rb', line 1676 def strings @strings end |
Class Method Details
.decode_rdata(msg) ⇒ Object
:nodoc:
1689 1690 1691 1692 |
# File 'lib/net/dns/resolv.rb', line 1689 def self.decode_rdata(msg) # :nodoc: strings = msg.get_string_list return self.new(*strings) end |
Instance Method Details
#data ⇒ Object
Returns the resource data as a single string. DNS uses multiple character strings to represent the data of a TXT record if the data is longer than 255 characters.
1681 1682 1683 |
# File 'lib/net/dns/resolv.rb', line 1681 def data @strings.join end |
#encode_rdata(msg) ⇒ Object
:nodoc:
1685 1686 1687 |
# File 'lib/net/dns/resolv.rb', line 1685 def encode_rdata(msg) # :nodoc: msg.put_string_list(@strings) end |