Class: PacketGen::Header::Base::Bindings Private
- Inherits:
-
Object
- Object
- PacketGen::Header::Base::Bindings
- Includes:
- Enumerable
- Defined in:
- lib/packetgen/header/base.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class to handle a set of header associations (Binding or/and ProcBinding)
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#<<(arg) ⇒ Bindings
private
Self.
-
#check?(fields) ⇒ Boolean
private
Check
fields
responds to set of bindings. -
#each {|binding| ... } ⇒ void
private
each iterator.
- #empty? ⇒ Boolean private
-
#initialize ⇒ Bindings
constructor
private
A new instance of Bindings.
- #new_set ⇒ Object private
-
#set(fields) ⇒ void
private
Set
fields
to bindings value. -
#to_h ⇒ Hash
private
Return bindings as a hash.
Constructor Details
#initialize ⇒ Bindings
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Bindings.
98 99 100 |
# File 'lib/packetgen/header/base.rb', line 98 def initialize @bindings = [] end |
Instance Attribute Details
#bindings ⇒ Array<Binding,ProcBinding>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
96 97 98 |
# File 'lib/packetgen/header/base.rb', line 96 def bindings @bindings end |
Instance Method Details
#<<(arg) ⇒ Bindings
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns self.
108 109 110 |
# File 'lib/packetgen/header/base.rb', line 108 def <<(arg) @bindings.last << arg end |
#check?(fields) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check fields
responds to set of bindings
137 138 139 |
# File 'lib/packetgen/header/base.rb', line 137 def check?(fields) @bindings.any? { |group| group.all? { |binding| binding.check?(fields) } } end |
#each {|binding| ... } ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
each iterator
115 116 117 |
# File 'lib/packetgen/header/base.rb', line 115 def each(&block) @bindings.each(&block) end |
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
120 121 122 |
# File 'lib/packetgen/header/base.rb', line 120 def empty? @bindings.empty? end |
#new_set ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
102 103 104 |
# File 'lib/packetgen/header/base.rb', line 102 def new_set @bindings << [] end |
#set(fields) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Set fields
to bindings value
144 145 146 |
# File 'lib/packetgen/header/base.rb', line 144 def set(fields) @bindings.first.each { |b| b.set(fields) } end |
#to_h ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return bindings as a hash.
126 127 128 129 130 131 132 |
# File 'lib/packetgen/header/base.rb', line 126 def to_h hsh = {} each do |b| b.each { |sb| hsh[sb.key] = sb.value } end hsh end |