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 header associations
Instance Attribute Summary collapse
- #bindings ⇒ Array<Binding> private
-
#op ⇒ :or, :and
private
op type.
Instance Method Summary collapse
-
#<<(arg) ⇒ Bindings
private
Self.
-
#check?(fields) ⇒ Boolean
private
Check
fieldsresponds to set of bindings. -
#each ⇒ void
private
each iterator.
- #empty? ⇒ Boolean private
-
#initialize(op) ⇒ Bindings
constructor
private
A new instance of Bindings.
-
#set(fields) ⇒ void
private
Set
fieldsto bindings value. - #to_h ⇒ Hash private
Constructor Details
#initialize(op) ⇒ 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.
81 82 83 84 |
# File 'lib/packetgen/header/base.rb', line 81 def initialize(op) @op = op @bindings = [] end |
Instance Attribute Details
#bindings ⇒ Array<Binding>
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.
78 79 80 |
# File 'lib/packetgen/header/base.rb', line 78 def bindings @bindings end |
#op ⇒ :or, :and
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.
op type
76 77 78 |
# File 'lib/packetgen/header/base.rb', line 76 def op @op 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.
88 89 90 |
# File 'lib/packetgen/header/base.rb', line 88 def <<(arg) @bindings << 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
113 114 115 116 117 118 119 120 |
# File 'lib/packetgen/header/base.rb', line 113 def check?(fields) case @op when :or empty? || @bindings.any? { |binding| binding.check?(fields) } when :and @bindings.all? { |binding| binding.check?(fields) } end end |
#each ⇒ 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
94 95 96 |
# File 'lib/packetgen/header/base.rb', line 94 def each @bindings.each { |b| yield b } 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.
99 100 101 |
# File 'lib/packetgen/header/base.rb', line 99 def empty? @bindings.empty? 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
125 126 127 |
# File 'lib/packetgen/header/base.rb', line 125 def set(fields) @bindings.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.
104 105 106 107 108 |
# File 'lib/packetgen/header/base.rb', line 104 def to_h hsh = {} each { |b| hsh[b.key] = b.value } hsh end |