Class: Unified2::Payload
- Inherits:
-
Object
- Object
- Unified2::Payload
- Defined in:
- lib/unified2/payload.rb
Overview
Payload
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
-
#linktype ⇒ Object
Returns the value of attribute linktype.
-
#packet ⇒ Object
Returns the value of attribute packet.
Instance Method Summary collapse
-
#blank? ⇒ true, false
Blank?.
-
#dump(options = {}) {|index, hex_segment, print_segment| ... } ⇒ nil
Dump.
-
#hex ⇒ String
Hex.
-
#initialize(raw, packet = {}) ⇒ Payload
constructor
Initialize payload object.
-
#raw ⇒ String
Raw.
Constructor Details
#initialize(raw, packet = {}) ⇒ Payload
Initialize payload object
21 22 23 24 25 |
# File 'lib/unified2/payload.rb', line 21 def initialize(raw, packet={}) @packet = raw @length = packet[:packet_length].to_i @linktype = packet[:linktype] end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
9 10 11 |
# File 'lib/unified2/payload.rb', line 9 def length @length end |
#linktype ⇒ Object
Returns the value of attribute linktype.
9 10 11 |
# File 'lib/unified2/payload.rb', line 9 def linktype @linktype end |
#packet ⇒ Object
Returns the value of attribute packet.
9 10 11 |
# File 'lib/unified2/payload.rb', line 9 def packet @packet end |
Instance Method Details
#blank? ⇒ true, false
Blank?
32 33 34 35 |
# File 'lib/unified2/payload.rb', line 32 def blank? return true unless @packet false end |
#dump(options = {}) {|index, hex_segment, print_segment| ... } ⇒ nil
Note:
Please view the hexdump documentation for more information. Hexdump is a great lib by @postmodern. (github.com/postmodern/hexdump)
Dump
98 99 100 |
# File 'lib/unified2/payload.rb', line 98 def dump(={}) Hexdump.dump(@packet, ) end |
#hex ⇒ String
Hex
51 52 53 54 55 |
# File 'lib/unified2/payload.rb', line 51 def hex @hex = @packet.to_s.unpack('H*') return @hex.first if @hex nil end |