Class: SeekLib::Sig

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/seeklib.rb

Instance Method Summary collapse

Instance Method Details

#get_dataObject



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

def get_data
  [
    self[:sig1].to_a,
    self[:sig2].to_a,
    self[:sig3].to_a,
    self[:avgl].to_a
  ]
end

#inspectObject



26
27
28
29
# File 'lib/seeklib.rb', line 26

def inspect
  data = get_data.map {|x| x.inspect}
  "#<Sig: #{data.join ' '}>"
end

#marshal_dumpObject

these methods might not be fast enough, but whatever



31
32
33
# File 'lib/seeklib.rb', line 31

def marshal_dump
  Marshal.dump get_data
end

#marshal_load(str) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/seeklib.rb', line 34

def marshal_load str
  array = Marshal.load str
  fields = [:sig1, :sig2, :sig3, :avgl]
  fields.zip(array).each do |field, data|
    data.each_index do |i|
      self[field][i] = data[i]
    end
  end
end