Class: PacketGen::Types::Int16Enum

Inherits:
Enum
  • Object
show all
Defined in:
lib/packetgen/types/enum.rb

Overview

Enumeration on 2-byte integer. See Enum.

Author:

  • Sylvain Daubert

Since:

  • 2.1.3

Direct Known Subclasses

Int16beEnum, Int16leEnum

Instance Attribute Summary

Attributes inherited from Enum

#enum

Attributes inherited from Int

#default, #endian, #value, #width

Instance Method Summary collapse

Methods inherited from Enum

#format_inspect, #to_human, #value=

Methods inherited from Int

#format_inspect, #nbits, #read, #sz, #to_f, #to_i, #to_s

Methods included from Fieldable

#format_inspect, #read, #sz, #to_human, #to_s, #type_name

Constructor Details

#initialize(enum, endian = :big, default = nil) ⇒ Int16Enum

Returns a new instance of Int16Enum.

Parameters:

  • enum (Hash)
  • endian (:big, :little) (defaults to: :big)
  • default (Integer, nil) (defaults to: nil)

    default value

Since:

  • 2.1.3



100
101
102
103
# File 'lib/packetgen/types/enum.rb', line 100

def initialize(enum, endian=:big, default=nil)
  super(enum, endian, 2, default)
  @packstr = { big: 'n', little: 'v' }
end