Class: FeideeUtils::Kbf

Inherits:
Object
  • Object
show all
Defined in:
lib/feidee_utils/kbf.rb

Constant Summary collapse

DatabaseName =
'mymoney.sqlite'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_stream) ⇒ Kbf

Returns a new instance of Kbf.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/feidee_utils/kbf.rb', line 14

def initialize(input_stream)
  Zip::File.open_buffer(input_stream) do |zipfile|
    zipfile.each do |entry|
      if entry.name == DatabaseName
        # Each call to get_input_stream will create a new stream
        @original_sqlite_db_entry = entry
        @db = FeideeUtils::Database.new(entry.get_input_stream, true)
      end
    end
  end
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



12
13
14
# File 'lib/feidee_utils/kbf.rb', line 12

def db
  @db
end

#zipfileObject (readonly)

Returns the value of attribute zipfile.



12
13
14
# File 'lib/feidee_utils/kbf.rb', line 12

def zipfile
  @zipfile
end

Class Method Details

.open_file(file_name) ⇒ Object



34
35
36
# File 'lib/feidee_utils/kbf.rb', line 34

def open_file(file_name)
  return Kbf.new(File.open(file_name))
end

Instance Method Details

#extract_original_sqlite(dest_file_path = nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/feidee_utils/kbf.rb', line 26

def extract_original_sqlite(dest_file_path = nil)
  FeideeUtils::Database.feidee_to_sqlite(
    @original_sqlite_db_entry.get_input_stream,
    dest_file_path
  )
end