Class: BinStruct::Int16beEnum

Inherits:
Int16Enum show all
Defined in:
lib/bin_struct/enum.rb

Overview

Enumeration on big endian 2-byte integer. See Enum.

Author:

  • Sylvain Daubert (2016-2024)

  • LemonTree55

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, #from_human, #nbits, #read, #sz, #to_f, #to_i, #to_s

Methods included from Structable

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

Constructor Details

#initialize(options = {}) ⇒ Int16beEnum

Returns a new instance of Int16beEnum.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :enum (Hash{::String => Integer})

    enumerated values. Default value is taken from first element unless given. This option is mandatory.

  • :value (Integer, ::String)
  • :default (Integer, ::String)


132
133
134
135
136
# File 'lib/bin_struct/enum.rb', line 132

def initialize(options = {})
  opts = options.slice(:enum, :default, :value)
  opts[:endian] = :big
  super(opts)
end