Class: PacketGen::StructFu::Int16
- Defined in:
- lib/packetgen/structfu.rb
Overview
Int16 is a two byte value.
Instance Attribute Summary
Attributes inherited from Int
#default, #endian, #value, #width
Instance Method Summary collapse
-
#initialize(v = nil, e = :big) ⇒ Int16
constructor
A new instance of Int16.
-
#to_s ⇒ Object
Returns a two byte value as a packed string.
Methods inherited from Int
Methods inherited from Struct
Constructor Details
#initialize(v = nil, e = :big) ⇒ Int16
Returns a new instance of Int16.
154 155 156 157 |
# File 'lib/packetgen/structfu.rb', line 154 def initialize(v=nil, e=:big) super(v,e,w=2) @packstr = (self.e == :big) ? "n" : "v" end |
Instance Method Details
#to_s ⇒ Object
Returns a two byte value as a packed string.
160 161 162 163 |
# File 'lib/packetgen/structfu.rb', line 160 def to_s @packstr = (self.e == :big) ? "n" : "v" [(self.v || self.d)].pack(@packstr) end |