Class: PacketGen::Header::Base::Binding Private
- Inherits:
-
Struct
- Object
- Struct
- PacketGen::Header::Base::Binding
- 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.
Simple class to handle a header association
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#check?(fields) ⇒ Boolean
private
Check
fieldsresponds to binding. -
#set(fields) ⇒ void
private
Set
fieldsfield to binding value.
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key
17 18 19 |
# File 'lib/packetgen/header/base.rb', line 17 def key @key end |
#value ⇒ Object
Returns the value of attribute value
17 18 19 |
# File 'lib/packetgen/header/base.rb', line 17 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
21 22 23 24 25 26 27 28 |
# File 'lib/packetgen/header/base.rb', line 21 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
33 34 35 36 37 38 39 40 |
# File 'lib/packetgen/header/base.rb', line 33 def set(fields) case self[:value] when Proc fields.send "#{self[:key]}=", self[:value].call(nil) else fields.send "#{self[:key]}=", self[:value] end end |