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)
  @zipfile = 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
        @sqlite_db = FeideeUtils::Database.new(entry.get_input_stream, true)
      end
    end
  end
end

Instance Attribute Details

#sqlite_dbObject (readonly)

Returns the value of attribute sqlite_db.



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

def sqlite_db
  @sqlite_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



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

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
# 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