Class: PacketGen::Types::String
- Inherits:
-
String
- Object
- String
- PacketGen::Types::String
- Includes:
- LengthFrom
- Defined in:
- lib/packetgen/types/string.rb
Overview
This class is just like regular String. It only adds #read and #sz methods to be compatible with others PacketGen::Types.
Instance Attribute Summary collapse
- #static_length ⇒ Integer readonly
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ String
constructor
A new instance of String.
-
#read(str) ⇒ String
(also: #from_human)
Self.
Methods included from LengthFrom
#initialize_length_from, #read_with_length_from
Constructor Details
#initialize(options = {}) ⇒ String
Returns a new instance of String.
24 25 26 27 28 |
# File 'lib/packetgen/types/string.rb', line 24 def initialize(={}) super() initialize_length_from() @static_length = [:static_length] end |
Instance Attribute Details
#static_length ⇒ Integer (readonly)
18 19 20 |
# File 'lib/packetgen/types/string.rb', line 18 def static_length @static_length end |
Instance Method Details
#read(str) ⇒ String Also known as: from_human
Returns self.
32 33 34 35 36 37 |
# File 'lib/packetgen/types/string.rb', line 32 def read(str) s = read_with_length_from(str) s = s[0, static_length] if static_length self.replace(s) self end |