Class: FFI::BooleanInt
- Inherits:
-
Object
- Object
- FFI::BooleanInt
- Includes:
- DataConverter
- Defined in:
- lib/ffi/boolean_int.rb
Overview
Converter generator for different sizes ints as boolean
Instance Attribute Summary collapse
-
#native_type ⇒ Object
readonly
Returns the value of attribute native_type.
Instance Method Summary collapse
-
#from_native(object_id, _context) ⇒ Object
Not Zero.
-
#initialize(int_type) ⇒ BooleanInt
constructor
A new instance of BooleanInt.
-
#to_native(obj, _context) ⇒ Object
Falsey = 0, Truthy = 1.
Constructor Details
#initialize(int_type) ⇒ BooleanInt
Returns a new instance of BooleanInt.
9 10 11 |
# File 'lib/ffi/boolean_int.rb', line 9 def initialize(int_type) @native_type = FFI.find_type(int_type) end |
Instance Attribute Details
#native_type ⇒ Object (readonly)
Returns the value of attribute native_type.
7 8 9 |
# File 'lib/ffi/boolean_int.rb', line 7 def native_type @native_type end |
Instance Method Details
#from_native(object_id, _context) ⇒ Object
Not Zero
19 20 21 |
# File 'lib/ffi/boolean_int.rb', line 19 def from_native(object_id, _context) !object_id.zero? end |
#to_native(obj, _context) ⇒ Object
Falsey = 0, Truthy = 1
14 15 16 |
# File 'lib/ffi/boolean_int.rb', line 14 def to_native(obj, _context) obj ? 1 : 0 end |