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
key
in this list. -
#add(param) ⇒ Object
Add the SvcParam
param
to 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
SvcParam
with the givenkey
and return it. -
#each(&block) ⇒ Object
Enumerate the SvcParams 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 SvcParams. If its content has SvcParams with the duplicate key, the one appears last takes precedence.
1716 1717 1718 1719 1720 1721 1722 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1716 def initialize(params = []) @params = {} params.each do |param| add param end end |
Class Method Details
.decode(msg) ⇒ Object
:nodoc:
1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1776 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.
1727 1728 1729 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1727 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.
1748 1749 1750 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1748 def add(param) @params[param.class.key_number] = param end |
#count ⇒ Object
Get the number of SvcParams in this list.
1734 1735 1736 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1734 def count @params.count end |
#delete(key) ⇒ Object
Remove the SvcParam
with the given key
and return it.
1755 1756 1757 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1755 def delete(key) @params.delete(canonical_key(key)) end |
#each(&block) ⇒ Object
Enumerate the SvcParams in this list.
1762 1763 1764 1765 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1762 def each(&block) return enum_for(:each) unless block @params.each_value(&block) end |
#empty? ⇒ Boolean
Get whether this list is empty.
1741 1742 1743 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1741 def empty? @params.empty? end |
#encode(msg) ⇒ Object
:nodoc:
1767 1768 1769 1770 1771 1772 1773 1774 |
# File 'lib/rubygems/vendor/resolv/lib/resolv.rb', line 1767 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 |