Class: Sigma::UnsignedInputs

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/sigma/input.rb

Overview

An ordered collection of UnsignedInput

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



247
248
249
# File 'lib/sigma/input.rb', line 247

def pointer
  @pointer
end

Class Method Details

.createUnsignedInputs

Create an empty collection

Returns:



259
260
261
262
263
264
# File 'lib/sigma/input.rb', line 259

def self.create
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_unsigned_inputs_new(pointer)

  init(pointer)
end

.with_raw_pointer(unread_pointer) ⇒ UnsignedInputs

Note:

A user of sigma_rb generally does not need to call this function

Takes ownership of an existing UnsignedInputs Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



253
254
255
# File 'lib/sigma/input.rb', line 253

def self.with_raw_pointer(unread_pointer)
  init(unread_pointer)
end

Instance Method Details

#add(unsigned_input) ⇒ Object

Add to collection

Parameters:



274
275
276
# File 'lib/sigma/input.rb', line 274

def add(unsigned_input)
  ergo_lib_unsigned_inputs_add(unsigned_input.pointer, self.pointer)
end

#get(index) ⇒ UnsignedInput?

Get item at specified index or return nil if no item exists

Returns:



281
282
283
284
285
286
287
288
289
290
# File 'lib/sigma/input.rb', line 281

def get(index)
  pointer = FFI::MemoryPointer.new(:pointer)
  res = ergo_lib_unsigned_inputs_get(self.pointer, index, pointer)
  Util.check_error!(res[:error])
  if res[:is_some]
    Sigma::UnsignedInput.with_raw_pointer(pointer)
  else
    nil
  end
end

#lenInteger

Get length of collection

Returns:

  • (Integer)


268
269
270
# File 'lib/sigma/input.rb', line 268

def len
  ergo_lib_unsigned_inputs_len(self.pointer)
end