Exception: CTypes::MissingBytesError

Inherits:
Error
  • Object
show all
Defined in:
lib/ctypes/missing_bytes_error.rb

Overview

Exception raised when attempting to unpack a Type that requires more bytes than were provided in the input.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, input:, need:) ⇒ MissingBytesError

Returns a new instance of MissingBytesError.



10
11
12
13
14
15
16
# File 'lib/ctypes/missing_bytes_error.rb', line 10

def initialize(type:, input:, need:)
  @type = type
  @input = input
  @need = need
  super("insufficent input to unpack %s; missing %d bytes" %
    [@type, missing])
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



17
18
19
# File 'lib/ctypes/missing_bytes_error.rb', line 17

def input
  @input
end

#needObject (readonly)

Returns the value of attribute need.



17
18
19
# File 'lib/ctypes/missing_bytes_error.rb', line 17

def need
  @need
end

#typeObject (readonly)

Returns the value of attribute type.



17
18
19
# File 'lib/ctypes/missing_bytes_error.rb', line 17

def type
  @type
end

Instance Method Details

#missingObject

get the number of additional bytes required to unpack this type



20
21
22
# File 'lib/ctypes/missing_bytes_error.rb', line 20

def missing
  @need - @input.size
end