Class: Sigma::PoPowHeader
- Inherits:
-
Object
- Object
- Sigma::PoPowHeader
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/nipopow.rb
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.with_json(json) ⇒ PoPowHeader
Create from json.
Instance Method Summary collapse
-
#==(other_header) ⇒ bool
Equality check.
-
#get_header ⇒ BlockHeader
Get header.
-
#get_interlinks ⇒ BlockIds
Get interlinks.
-
#to_json ⇒ String
JSON representation.
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
122 123 124 |
# File 'lib/sigma/nipopow.rb', line 122 def pointer @pointer end |
Class Method Details
.with_json(json) ⇒ PoPowHeader
Create from json
127 128 129 130 131 132 |
# File 'lib/sigma/nipopow.rb', line 127 def self.with_json(json) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_popow_header_from_json(json, pointer) Util.check_error!(error) init(pointer) end |
Instance Method Details
#==(other_header) ⇒ bool
Equality check
167 168 169 |
# File 'lib/sigma/nipopow.rb', line 167 def ==(other_header) ergo_lib_po_pow_header_eq(self.pointer, other_header.pointer) end |
#get_header ⇒ BlockHeader
Get header
148 149 150 151 152 153 |
# File 'lib/sigma/nipopow.rb', line 148 def get_header pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_popow_header_get_header(self.pointer, pointer) Util.check_error!(error) BlockHeader.with_raw_pointer(pointer) end |
#get_interlinks ⇒ BlockIds
Get interlinks
157 158 159 160 161 162 |
# File 'lib/sigma/nipopow.rb', line 157 def get_interlinks pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_popow_header_get_interlinks(self.pointer, pointer) Util.check_error!(error) BlockIds.with_raw_pointer(pointer) end |
#to_json ⇒ String
JSON representation
136 137 138 139 140 141 142 143 144 |
# File 'lib/sigma/nipopow.rb', line 136 def to_json s_ptr = FFI::MemoryPointer.new(:pointer, 1) error = ergo_lib_popow_header_to_json(self.pointer, s_ptr) Util.check_error!(error) s_ptr = s_ptr.read_pointer() str = s_ptr.read_string().force_encoding('UTF-8') Util.ergo_lib_delete_string(s_ptr) str end |