Class: Sigma::Inputs
- Inherits:
-
Object
- Object
- Sigma::Inputs
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/input.rb
Overview
An ordered collectino of Input
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.create ⇒ Inputs
Create an empty collection.
-
.with_raw_pointer(unread_pointer) ⇒ Inputs
Takes ownership of an existing Inputs Pointer.
Instance Method Summary collapse
-
#add(input) ⇒ Object
Add to collection.
-
#get(index) ⇒ Input?
Get item at specified index or return nil if no item exists.
-
#len ⇒ Integer
Get length of collection.
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
65 66 67 |
# File 'lib/sigma/input.rb', line 65 def pointer @pointer end |
Class Method Details
.create ⇒ Inputs
Create an empty collection
77 78 79 80 81 82 |
# File 'lib/sigma/input.rb', line 77 def self.create pointer = FFI::MemoryPointer.new(:pointer) ergo_lib_inputs_new(pointer) init(pointer) end |
.with_raw_pointer(unread_pointer) ⇒ Inputs
Note:
A user of sigma_rb generally does not need to call this function
Takes ownership of an existing Inputs Pointer.
71 72 73 |
# File 'lib/sigma/input.rb', line 71 def self.with_raw_pointer(unread_pointer) init(unread_pointer) end |
Instance Method Details
#add(input) ⇒ Object
Add to collection
92 93 94 |
# File 'lib/sigma/input.rb', line 92 def add(input) ergo_lib_inputs_add(input.pointer, self.pointer) end |
#get(index) ⇒ Input?
Get item at specified index or return nil if no item exists
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/sigma/input.rb', line 99 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 |
#len ⇒ Integer
Get length of collection
86 87 88 |
# File 'lib/sigma/input.rb', line 86 def len ergo_lib_inputs_len(self.pointer) end |