Class: Sigma::Inputs

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



55
56
57
# File 'lib/sigma/input.rb', line 55

def pointer
  @pointer
end

Class Method Details

.createObject



61
62
63
64
65
66
# File 'lib/sigma/input.rb', line 61

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

  init(pointer)
end

.with_raw_pointer(unread_pointer) ⇒ Object



57
58
59
# File 'lib/sigma/input.rb', line 57

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

Instance Method Details

#add(input) ⇒ Object



72
73
74
# File 'lib/sigma/input.rb', line 72

def add(input)
  ergo_lib_inputs_add(input.pointer, self.pointer)
end

#get(index) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/sigma/input.rb', line 76

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

#lenObject



68
69
70
# File 'lib/sigma/input.rb', line 68

def len
  ergo_lib_inputs_len(self.pointer)
end