Class: PacketGen::Header::Base::Bindings Private
- Inherits:
-
Object
- Object
- PacketGen::Header::Base::Bindings
- Includes:
- Enumerable
- Defined in:
- lib/packetgen/header/base.rb,
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.
54 55 56 57 |
# File 'lib/packetgen/header/base.rb', line 54 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.
51 52 53 |
# File 'lib/packetgen/header/base.rb', line 51 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
49 50 51 |
# File 'lib/packetgen/header/base.rb', line 49 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.
61 62 63 |
# File 'lib/packetgen/header/base.rb', line 61 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
86 87 88 89 90 91 92 93 |
# File 'lib/packetgen/header/base.rb', line 86 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
67 68 69 |
# File 'lib/packetgen/header/base.rb', line 67 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.
72 73 74 |
# File 'lib/packetgen/header/base.rb', line 72 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
98 99 100 |
# File 'lib/packetgen/header/base.rb', line 98 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.
77 78 79 80 81 |
# File 'lib/packetgen/header/base.rb', line 77 def to_h hsh = {} each { |b| hsh[b.key] = b.value } hsh end |