class Zold::Txns

A collection of transactions

Public Class Methods

new(file) click to toggle source
# File lib/zold/txns.rb, line 35
def initialize(file)
  @file = file
end

Public Instance Methods

fetch() click to toggle source
# File lib/zold/txns.rb, line 43
def fetch
  raise "Wallet file '#{@file}' is absent" unless File.exist?(@file)
  txns = []
  i = 0
  File.open(@file) do |f|
    until f.eof?
      line = f.readline
      i += 1
      next if i < 5
      next if line.strip.empty?
      txns << Txn.parse(line, i)
    end
  end
  raise CantParse, "Not enough lines in #{@file}, just #{i}" if i < 4
  txns.sort
end
flush() click to toggle source
# File lib/zold/txns.rb, line 39
def flush
  # nothing
end