Exception: CTypes::MissingBytesError
- 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
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#need ⇒ Object
readonly
Returns the value of attribute need.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, input:, need:) ⇒ MissingBytesError
constructor
A new instance of MissingBytesError.
-
#missing ⇒ Object
get the number of additional bytes required to unpack this type.
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
#input ⇒ Object (readonly)
Returns the value of attribute input.
17 18 19 |
# File 'lib/ctypes/missing_bytes_error.rb', line 17 def input @input end |
#need ⇒ Object (readonly)
Returns the value of attribute need.
17 18 19 |
# File 'lib/ctypes/missing_bytes_error.rb', line 17 def need @need end |
#type ⇒ Object (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
#missing ⇒ Object
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 |