Class: Sigma::BoxValue
- Inherits:
-
Object
- Object
- Sigma::BoxValue
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/ergo_box.rb
Overview
Box value in nanoERGs with bound checks
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.from_i64(int) ⇒ BoxValue
Create BoxValue from 64-bit integer.
-
.safe_user_min ⇒ Object
Recommended (safe) minimal box value to use in case box size estimation is unavailable.
-
.sum_of(bv_one, bv_two) ⇒ Object
Create a new box value which is the sum of the arguments, throwing error if value is out of bounds.
-
.units_per_ergo ⇒ Object
Number of units inside one ERGO (i.e. one ERG using nano ERG representation).
-
.with_raw_pointer(bv_pointer) ⇒ BoxValue
Takes ownership of an existing BoxValue Pointer.
Instance Method Summary collapse
-
#==(box_value_two) ⇒ bool
Equality check for two BoxValues.
-
#to_i64 ⇒ Integer
Get value as 64-bit integer.
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
92 93 94 |
# File 'lib/sigma/ergo_box.rb', line 92 def pointer @pointer end |
Class Method Details
.from_i64(int) ⇒ BoxValue
Create BoxValue from 64-bit integer
127 128 129 130 131 132 133 |
# File 'lib/sigma/ergo_box.rb', line 127 def self.from_i64(int) bv_ptr = FFI::MemoryPointer.new(:pointer) error = ergo_lib_box_value_from_i64(int, bv_ptr) Util.check_error!(error) init(bv_ptr) end |
.safe_user_min ⇒ Object
Recommended (safe) minimal box value to use in case box size estimation is unavailable. Allows box size upto 2777 bytes with current min box value per byte of 360 nanoERGs
109 110 111 112 113 114 |
# File 'lib/sigma/ergo_box.rb', line 109 def self.safe_user_min bv_ptr = FFI::MemoryPointer.new(:pointer) ergo_lib_box_value_safe_user_min(bv_ptr) init(bv_ptr) end |
.sum_of(bv_one, bv_two) ⇒ Object
Create a new box value which is the sum of the arguments, throwing error if value is out of bounds.
116 117 118 119 120 121 122 |
# File 'lib/sigma/ergo_box.rb', line 116 def self.sum_of(bv_one, bv_two) bv_ptr = FFI::MemoryPointer.new(:pointer) error = ergo_lib_box_value_sum_of(bv_one.pointer, bv_two.pointer, bv_ptr) Util.check_error!(error) init(bv_ptr) end |
.units_per_ergo ⇒ Object
Number of units inside one ERGO (i.e. one ERG using nano ERG representation)
103 104 105 |
# File 'lib/sigma/ergo_box.rb', line 103 def self.units_per_ergo ergo_lib_box_value_units_per_ergo end |
.with_raw_pointer(bv_pointer) ⇒ BoxValue
A user of sigma_rb generally does not need to call this function
Takes ownership of an existing BoxValue Pointer.
98 99 100 |
# File 'lib/sigma/ergo_box.rb', line 98 def self.with_raw_pointer(bv_pointer) init(bv_pointer) end |
Instance Method Details
#==(box_value_two) ⇒ bool
Equality check for two BoxValues
144 145 146 |
# File 'lib/sigma/ergo_box.rb', line 144 def ==(box_value_two) ergo_lib_box_value_eq(self.pointer, box_value_two.pointer) end |
#to_i64 ⇒ Integer
Get value as 64-bit integer
137 138 139 |
# File 'lib/sigma/ergo_box.rb', line 137 def to_i64 ergo_lib_box_value_as_i64(self.pointer) end |