Class: PacketGen::StructFu::Int8

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

Overview

Int8 is a one byte value.

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) ⇒ Int8

Returns a new instance of Int8.



141
142
143
144
# File 'lib/packetgen/structfu.rb', line 141

def initialize(v=nil)
  super(v,nil,w=1)
  @packstr = "C"
end

Instance Method Details

#to_sObject

Returns a one byte value as a packed string.



147
148
149
# File 'lib/packetgen/structfu.rb', line 147

def to_s
  [(self.v || self.d)].pack("C")
end