Class: Numerix::Structure Abstract
- Inherits:
-
Object
- Object
- Numerix::Structure
- Defined in:
- lib/numerix/structure.rb
Overview
Abstract class providing common functionality to the base classes.
This class cannot be instantiated, it of only for providing a common base class for all Numerix types and provide common functionality.
Direct Known Subclasses
Class Method Summary collapse
-
.size ⇒ Integer
The size, in bytes, the structure contains in memory.
-
.unpack(binary) ⇒ Object
(also: _load)
Unpacks a binary string of data into a structure.
Instance Method Summary collapse
-
#[](index) ⇒ Float?
Retrieves the component of the structure at the specified position.
-
#[]=(index, value) ⇒ Float
Sets the component of the structure at the specified position.
-
#address ⇒ Integer
The address of the internal C-struct in memory.
-
#dup ⇒ Object
An exact duplicate of the object.
-
#each ⇒ Object
Enumerates over the components of the structure.
-
#pack ⇒ String
(also: #_dump)
Packs the structures memory into a binary string.
-
#ptr ⇒ Fiddle::Pointer
A sized pointer to the structure in memory.
Class Method Details
.size ⇒ Integer
Returns the size, in bytes, the structure contains in memory.
103 104 |
# File 'lib/numerix/structure.rb', line 103 def size end |
.unpack(binary) ⇒ Object Also known as: _load
Unpacks a binary string of data into a structure.
This is the equivalent of calling binary.unpack('f*') on the string
and using the values to create a new structure, but much faster as it
bypasses the parser and is done in C directly with a pointer in memory.
118 119 |
# File 'lib/numerix/structure.rb', line 118 def unpack(binary) end |
Instance Method Details
#[](index) ⇒ Float?
Retrieves the component of the structure at the specified position.
52 53 |
# File 'lib/numerix/structure.rb', line 52 def [](index) end |
#[]=(index, value) ⇒ Float
Sets the component of the structure at the specified position.
If index is out of range, the method does nothing.
66 67 |
# File 'lib/numerix/structure.rb', line 66 def []=(index, value) end |
#address ⇒ Integer
Returns the address of the internal C-struct in memory.
20 21 |
# File 'lib/numerix/structure.rb', line 20 def address end |
#dup ⇒ Object
Returns an exact duplicate of the object.
15 16 |
# File 'lib/numerix/structure.rb', line 15 def dup end |
#each {|component| ... } ⇒ self #each ⇒ Enumerator
Enumerates over the components of the structure.
40 41 |
# File 'lib/numerix/structure.rb', line 40 def each end |
#pack ⇒ String Also known as: _dump
Packs the structures memory into a binary string.
This is the equivalent of taking its values into an array and calling
array.pack('f*') on it, though considerably faster as the parser is
bypassed and done directly in C by accessing the memory directly.
79 80 |
# File 'lib/numerix/structure.rb', line 79 def pack end |
#ptr ⇒ Fiddle::Pointer
This method only exists in Ruby 2.0 and higher, and will not be present in lower versions.
Returns a sized pointer to the structure in memory.
95 96 |
# File 'lib/numerix/structure.rb', line 95 def ptr end |