### Home Classes Methods

### In Files

- lib/packetfu/structfu.rb

### Parent

Struct.new(:value, :endian, :width, :default)

### Methods

- ::new
- #read
- #to_f
- #to_i
- #to_s

### Files

- .document
- README.rdoc

### Class/Module Index

Quicksearch

- PacketFu
- PacketFu::ARPHeader
- PacketFu::ARPHeaderMixin
- PacketFu::ARPPacket
- PacketFu::AddrIpv6
- PacketFu::Capture
- PacketFu::Config
- PacketFu::EthHeader
- PacketFu::EthHeaderMixin
- PacketFu::EthMac
- PacketFu::EthNic
- PacketFu::EthOui
- PacketFu::EthPacket
- PacketFu::HSRPHeader
- PacketFu::HSRPHeaderMixin
- PacketFu::HSRPPacket
- PacketFu::ICMPHeader
- PacketFu::ICMPHeaderMixin
- PacketFu::ICMPPacket
- PacketFu::IPHeader
- PacketFu::IPHeaderMixin
- PacketFu::IPPacket
- PacketFu::IPv6Header
- PacketFu::IPv6HeaderMixin
- PacketFu::IPv6Packet
- PacketFu::Inject
- PacketFu::InvalidHeader
- PacketFu::InvalidPacket
- PacketFu::LLDPHeader
- PacketFu::LLDPHeaderMixin
- PacketFu::LLDPPacket
- PacketFu::Octets
- PacketFu::Packet
- PacketFu::PcapFile
- PacketFu::PcapHeader
- PacketFu::PcapPacket
- PacketFu::PcapPackets
- PacketFu::Read
- PacketFu::TCPHeader
- PacketFu::TCPHeaderMixin
- PacketFu::TCPPacket
- PacketFu::TcpEcn
- PacketFu::TcpFlags
- PacketFu::TcpHlen
- PacketFu::TcpOption
- PacketFu::TcpOption::ECHO
- PacketFu::TcpOption::ECHOREPLY
- PacketFu::TcpOption::EOL
- PacketFu::TcpOption::MSS
- PacketFu::TcpOption::NOP
- PacketFu::TcpOption::SACK
- PacketFu::TcpOption::SACKOK
- PacketFu::TcpOption::TS
- PacketFu::TcpOption::WS
- PacketFu::TcpOptions
- PacketFu::TcpReserved
- PacketFu::Timestamp
- PacketFu::UDPHeader
- PacketFu::UDPHeaderMixin
- PacketFu::UDPPacket
- PacketFu::Utils
- PacketFu::Write
- StructFu
- StructFu::Int
- StructFu::Int16
- StructFu::Int16be
- StructFu::Int16le
- StructFu::Int32
- StructFu::Int32be
- StructFu::Int32le
- StructFu::Int8
- StructFu::IntString
- StructFu::String
- Struct

No matching classes.

# StructFu::Int

Ints all have a value, an endianness, and a default value. Note that the signedness of Int values are implicit as far as the subclasses are concerned; to_i and to_f will return Integer/Float versions of the input value, instead of attempting to unpack the pack value. (This can be a useful hint to other functions).

#### Header Definition

    Fixnum  :value
    Symbol  :endian
    Fixnum  :width
    Fixnum  :default

### Public Class Methods

new(value=nil, endian=nil, width=nil, default=nil) click to toggle source

    # File lib/packetfu/structfu.rb, line 83
    def initialize(value=nil, endian=nil, width=nil, default=nil)
            super(value,endian,width,default=0)
    end

### Public Instance Methods

read(i) click to toggle source

Reads either an Integer or a packed string, and populates the value accordingly.

    # File lib/packetfu/structfu.rb, line 88
    def read(i)
            self.v = i.kind_of?(Integer) ? i.to_i : i.to_s.unpack(@packstr).first
            self
    end

to_f() click to toggle source

Returns the Int as a Float.

    # File lib/packetfu/structfu.rb, line 79
    def to_f
            (self.v || self.d).to_f
    end

to_i() click to toggle source

Returns the Int as an Integer.

    # File lib/packetfu/structfu.rb, line 74
    def to_i
            (self.v || self.d).to_i
    end

to_s() click to toggle source

This is a parent class definition and should not be used directly.

    # File lib/packetfu/structfu.rb, line 69
    def to_s
            raise StandardError, "StructFu::Int#to_s accessed, must be redefined."
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.