Class: PacketGen::Header::Base::Bindings Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeBindings

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.



87
88
89
# File 'lib/packetgen/header/base.rb', line 87

def initialize
  @bindings = []
end

Instance Attribute Details

#bindingsArray<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.

Returns:



85
86
87
# File 'lib/packetgen/header/base.rb', line 85

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.

Parameters:

  • arg (Object)

Returns:



97
98
99
# File 'lib/packetgen/header/base.rb', line 97

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

Parameters:

Returns:

  • (Boolean)


125
126
127
# File 'lib/packetgen/header/base.rb', line 125

def check?(fields)
  @bindings.any? { |group| group.all? { |binding| binding.check?(fields) } }
end

#each(&block) ⇒ 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



103
104
105
# File 'lib/packetgen/header/base.rb', line 103

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.

Returns:

  • (Boolean)


108
109
110
# File 'lib/packetgen/header/base.rb', line 108

def empty?
  @bindings.empty?
end

#new_setObject

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.



91
92
93
# File 'lib/packetgen/header/base.rb', line 91

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

Parameters:



132
133
134
# File 'lib/packetgen/header/base.rb', line 132

def set(fields)
  @bindings.first.each { |b| b.set fields }
end

#to_hHash

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 binding as a hash.

Returns:

  • (Hash)


114
115
116
117
118
119
120
# File 'lib/packetgen/header/base.rb', line 114

def to_h
  hsh = {}
  each do |b|
    b.each { |sb| hsh[sb.key] = sb.value }
  end
  hsh
end