Class: PacketGen::StructFu::Int32

Inherits:
Int
  • Object
show all
Defined in:
lib/packetgen/structfu.rb

Overview

Int32 is a four byte value.

Direct Known Subclasses

Int32be, Int32le

Instance Attribute Summary

Attributes inherited from Int

#default, #endian, #value, #width

Instance Method Summary collapse

Methods inherited from Int

#read, #to_f, #to_i

Methods inherited from Struct

#force_binary

Constructor Details

#initialize(v = nil, e = :big) ⇒ Int32

Returns a new instance of Int32.



184
185
186
187
# File 'lib/packetgen/structfu.rb', line 184

def initialize(v=nil, e=:big)
  super(v,e,w=4)
  @packstr = (self.e == :big) ? "N" : "V"
end

Instance Method Details

#to_sObject

Returns a four byte value as a packed string.



190
191
192
193
# File 'lib/packetgen/structfu.rb', line 190

def to_s
  @packstr = (self.e == :big) ? "N" : "V"
  [(self.v || self.d)].pack(@packstr)
end