Class: LibSSW::Profile

Inherits:
FFI::Profile
  • Object
show all
Defined in:
lib/libssw/profile.rb

Overview

structure of the query profile/usr/lib/x86_64-linux-gnu/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Profile

Returns a new instance of Profile.



18
19
20
21
22
23
24
25
26
# File 'lib/libssw/profile.rb', line 18

def initialize(ptr)
  @ptr      = ptr
  @cstruct  = profile = LibSSW::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

#biasObject

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/libssw/profile.rb', line 10

class Profile < FFI::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 = LibSSW::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

#matObject

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/libssw/profile.rb', line 10

class Profile < FFI::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 = LibSSW::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

#nObject

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/libssw/profile.rb', line 10

class Profile < FFI::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 = LibSSW::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

#readObject

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/libssw/profile.rb', line 10

class Profile < FFI::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 = LibSSW::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_lenObject

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/libssw/profile.rb', line 10

class Profile < FFI::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 = LibSSW::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

.keysObject



11
12
13
# File 'lib/libssw/profile.rb', line 11

def self.keys
  %i[read mat read_len n bias]
end

Instance Method Details

#to_hObject



38
39
40
# File 'lib/libssw/profile.rb', line 38

def to_h
  self.class.keys.map { |k| [k, __send__(k)] }.to_h
end

#to_ptrObject



28
29
30
31
32
33
34
35
36
# File 'lib/libssw/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