Class: PacketGen::Header::Base::Binding Private
- Inherits:
-
Struct
- Object
- Struct
- PacketGen::Header::Base::Binding
- Defined in:
- lib/packetgen/header/base.rb,
lib/packetgen/header/base.rb
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.
Instance Attribute Summary collapse
-
#key ⇒ Symbol
attribute name in a header.
-
#value ⇒ Integer, ...
Value associated with the attribute to create a binding.
Instance Method Summary collapse
-
#check?(fields) ⇒ Boolean
private
Check
fields
responds to binding. -
#set(fields) ⇒ void
private
Set
fields
field to binding value.
Instance Attribute Details
#key ⇒ Symbol
attribute name in a header
5 6 7 |
# File 'lib/packetgen/header/base.rb', line 5 def key @key end |
#value ⇒ Integer, ...
Value associated with the attribute to create a binding
8 9 10 |
# File 'lib/packetgen/header/base.rb', line 8 def value @value end |
Instance Method Details
#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 binding
38 39 40 41 42 43 44 45 |
# File 'lib/packetgen/header/base.rb', line 38 def check?(fields) case self[:value] when Proc self[:value].call(fields.send(self[:key])) else fields.send(self[:key]) == self[:value] end 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
field to binding value
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/packetgen/header/base.rb', line 50 def set(fields) case self[:value] when Proc fields.send(:"#{self[:key]}=", self[:value].call(nil)) else attr = if self[:key].to_s.end_with?('?') self[:key].to_s[0..-2] else self[:key] end fields.send(:"#{attr}=", self[:value]) end end |