Class: SSW::Profile
- Inherits:
-
Object
- Object
- SSW::Profile
- Defined in:
- lib/ssw/profile.rb
Overview
structure of the query profile/usr/lib/x86_64-linux-gnu/
Instance Attribute Summary collapse
-
#bias ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/.
-
#mat ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/.
-
#n ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/.
-
#read ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/.
-
#read_len ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ptr) ⇒ Profile
constructor
A new instance of Profile.
- #to_h ⇒ Object
- #to_ptr ⇒ Object
Constructor Details
#initialize(ptr) ⇒ Profile
Returns a new instance of Profile.
18 19 20 21 22 23 24 25 26 |
# File 'lib/ssw/profile.rb', line 18 def initialize(ptr) @ptr = ptr @cstruct = profile = SSW::FFI::Profile.new(ptr) @read_len = profile.readLen @read = read_len.positive? ? profile.read[0, read_len].unpack('c*') : [] @n = profile.n @mat = n.positive? ? profile.mat[0, n * n].unpack('c*') : [] @bias = profile.bias end |
Instance Attribute Details
#bias ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ssw/profile.rb', line 10 class Profile def self.keys %i[read mat read_len n bias] end # This class is read_only attr_reader(*keys, :ptr, :cstruct) def initialize(ptr) @ptr = ptr @cstruct = profile = SSW::FFI::Profile.new(ptr) @read_len = profile.readLen @read = read_len.positive? ? profile.read[0, read_len].unpack('c*') : [] @n = profile.n @mat = n.positive? ? profile.mat[0, n * n].unpack('c*') : [] @bias = profile.bias end def to_ptr # Garbage collection warkaround # Preventing Garbage Collection --force cstruct.read = ptr.instance_variable_get(:@read_str) cstruct.mat = ptr.instance_variable_get(:@mat_str) cstruct.readLen = ptr.instance_variable_get(:@read_len) cstruct.n = ptr.instance_variable_get(:@n) ptr end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end end |
#mat ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ssw/profile.rb', line 10 class Profile def self.keys %i[read mat read_len n bias] end # This class is read_only attr_reader(*keys, :ptr, :cstruct) def initialize(ptr) @ptr = ptr @cstruct = profile = SSW::FFI::Profile.new(ptr) @read_len = profile.readLen @read = read_len.positive? ? profile.read[0, read_len].unpack('c*') : [] @n = profile.n @mat = n.positive? ? profile.mat[0, n * n].unpack('c*') : [] @bias = profile.bias end def to_ptr # Garbage collection warkaround # Preventing Garbage Collection --force cstruct.read = ptr.instance_variable_get(:@read_str) cstruct.mat = ptr.instance_variable_get(:@mat_str) cstruct.readLen = ptr.instance_variable_get(:@read_len) cstruct.n = ptr.instance_variable_get(:@n) ptr end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end end |
#n ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ssw/profile.rb', line 10 class Profile def self.keys %i[read mat read_len n bias] end # This class is read_only attr_reader(*keys, :ptr, :cstruct) def initialize(ptr) @ptr = ptr @cstruct = profile = SSW::FFI::Profile.new(ptr) @read_len = profile.readLen @read = read_len.positive? ? profile.read[0, read_len].unpack('c*') : [] @n = profile.n @mat = n.positive? ? profile.mat[0, n * n].unpack('c*') : [] @bias = profile.bias end def to_ptr # Garbage collection warkaround # Preventing Garbage Collection --force cstruct.read = ptr.instance_variable_get(:@read_str) cstruct.mat = ptr.instance_variable_get(:@mat_str) cstruct.readLen = ptr.instance_variable_get(:@read_len) cstruct.n = ptr.instance_variable_get(:@n) ptr end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end end |
#read ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ssw/profile.rb', line 10 class Profile def self.keys %i[read mat read_len n bias] end # This class is read_only attr_reader(*keys, :ptr, :cstruct) def initialize(ptr) @ptr = ptr @cstruct = profile = SSW::FFI::Profile.new(ptr) @read_len = profile.readLen @read = read_len.positive? ? profile.read[0, read_len].unpack('c*') : [] @n = profile.n @mat = n.positive? ? profile.mat[0, n * n].unpack('c*') : [] @bias = profile.bias end def to_ptr # Garbage collection warkaround # Preventing Garbage Collection --force cstruct.read = ptr.instance_variable_get(:@read_str) cstruct.mat = ptr.instance_variable_get(:@mat_str) cstruct.readLen = ptr.instance_variable_get(:@read_len) cstruct.n = ptr.instance_variable_get(:@n) ptr end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end end |
#read_len ⇒ Object
structure of the query profile/usr/lib/x86_64-linux-gnu/
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ssw/profile.rb', line 10 class Profile def self.keys %i[read mat read_len n bias] end # This class is read_only attr_reader(*keys, :ptr, :cstruct) def initialize(ptr) @ptr = ptr @cstruct = profile = SSW::FFI::Profile.new(ptr) @read_len = profile.readLen @read = read_len.positive? ? profile.read[0, read_len].unpack('c*') : [] @n = profile.n @mat = n.positive? ? profile.mat[0, n * n].unpack('c*') : [] @bias = profile.bias end def to_ptr # Garbage collection warkaround # Preventing Garbage Collection --force cstruct.read = ptr.instance_variable_get(:@read_str) cstruct.mat = ptr.instance_variable_get(:@mat_str) cstruct.readLen = ptr.instance_variable_get(:@read_len) cstruct.n = ptr.instance_variable_get(:@n) ptr end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end end |
Class Method Details
.keys ⇒ Object
11 12 13 |
# File 'lib/ssw/profile.rb', line 11 def self.keys %i[read mat read_len n bias] end |
Instance Method Details
#to_h ⇒ Object
38 39 40 |
# File 'lib/ssw/profile.rb', line 38 def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end |
#to_ptr ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/ssw/profile.rb', line 28 def to_ptr # Garbage collection warkaround # Preventing Garbage Collection --force cstruct.read = ptr.instance_variable_get(:@read_str) cstruct.mat = ptr.instance_variable_get(:@mat_str) cstruct.readLen = ptr.instance_variable_get(:@read_len) cstruct.n = ptr.instance_variable_get(:@n) ptr end |