Class: Sigma::ErgoBoxCandidates

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

Overview

An ordered collection of ErgoBoxCandidate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



263
264
265
# File 'lib/sigma/ergo_box.rb', line 263

def pointer
  @pointer
end

Class Method Details

.createErgoBoxCandidates

Create an empty collection

Returns:



267
268
269
270
271
272
# File 'lib/sigma/ergo_box.rb', line 267

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

  init(pointer)
end

.with_raw_pointer(pointer) ⇒ ErgoBoxCandidates

Note:

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

Takes ownership of an existing ErgoBoxCandidates Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



278
279
280
# File 'lib/sigma/ergo_box.rb', line 278

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

Instance Method Details

#add(ergo_box_candidate) ⇒ Object

Add to collection

Parameters:



290
291
292
# File 'lib/sigma/ergo_box.rb', line 290

def add(ergo_box_candidate)
  ergo_lib_ergo_box_candidates_add(ergo_box_candidate.pointer, self.pointer)
end

#get(index) ⇒ ErgoBoxCandidate?

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

Parameters:

  • index (Integer)

Returns:



297
298
299
300
301
302
303
304
305
306
# File 'lib/sigma/ergo_box.rb', line 297

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

#lenInteger

Get length of collection

Returns:

  • (Integer)


284
285
286
# File 'lib/sigma/ergo_box.rb', line 284

def len
  ergo_lib_ergo_box_candidates_len(self.pointer)
end