Class: StructFu::Int16
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.
113 114 115 116 |
# File 'lib/packetfu/structfu.rb', line 113 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.
119 120 121 122 |
# File 'lib/packetfu/structfu.rb', line 119 def to_s @packstr = (self.e == :big) ? "n" : "v" [(self.v || self.d)].pack(@packstr) end |