Class: Gem::Resolv::DNS::SvcParams
- Inherits:
-
Object
- Object
- Gem::Resolv::DNS::SvcParams
- Includes:
- Enumerable
- Defined in:
- lib/rubygems/vendor/resolv/lib/resolv.rb
Overview
SvcParams for service binding RRs. [RFC9460]
Class Method Summary collapse
-
.decode(msg) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get SvcParam for the given
keyin this list. -
#add(param) ⇒ Object
Add the SvcParam
paramto this list, overwriting the existing one with the same key. -
#count ⇒ Object
Get the number of SvcParams in this list.
-
#delete(key) ⇒ Object
Remove the
SvcParamwith the givenkeyand return it. -
#each(&block) ⇒ Object
Enumerate the +SvcParam+s in this list.
-
#empty? ⇒ Boolean
Get whether this list is empty.
-
#encode(msg) ⇒ Object
:nodoc:.
-
#initialize(params = []) ⇒ SvcParams
constructor
Create a list of SvcParams with the given initial content.
Constructor Details
#initialize(params = []) ⇒ SvcParams
Create a list of SvcParams with the given initial content.
params has to be an enumerable of +SvcParam+s.
If its content has +SvcParam+s with the duplicate key,
the one appears last takes precedence.
1752 1753 1754 1755 1756 1757 1758 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1752 def initialize(params = []) @params = {} params.each do |param| add param end end |
Class Method Details
.decode(msg) ⇒ Object
:nodoc:
1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1812 def self.decode(msg) # :nodoc: params = msg.get_list do key, = msg.get_unpack('n') msg.get_length16 do SvcParam::ClassHash[key].decode(msg) end end return self.new(params) end |
Instance Method Details
#[](key) ⇒ Object
Get SvcParam for the given key in this list.
1763 1764 1765 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1763 def [](key) @params[canonical_key(key)] end |
#add(param) ⇒ Object
Add the SvcParam param to this list, overwriting the existing one with the same key.
1784 1785 1786 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1784 def add(param) @params[param.class.key_number] = param end |
#count ⇒ Object
Get the number of SvcParams in this list.
1770 1771 1772 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1770 def count @params.count end |
#delete(key) ⇒ Object
Remove the SvcParam with the given key and return it.
1791 1792 1793 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1791 def delete(key) @params.delete(canonical_key(key)) end |
#each(&block) ⇒ Object
Enumerate the +SvcParam+s in this list.
1798 1799 1800 1801 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1798 def each(&block) return enum_for(:each) unless block @params.each_value(&block) end |
#empty? ⇒ Boolean
Get whether this list is empty.
1777 1778 1779 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1777 def empty? @params.empty? end |
#encode(msg) ⇒ Object
:nodoc:
1803 1804 1805 1806 1807 1808 1809 1810 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1803 def encode(msg) # :nodoc: @params.keys.sort.each do |key| msg.put_pack('n', key) msg.put_length16 do @params.fetch(key).encode(msg) end end end |