Class: Zold::Txns

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/txns.rb

Overview

A collection of transactions

Defined Under Namespace

Classes: Cached

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Txns

Returns a new instance of Txns.



32
33
34
# File 'lib/zold/txns.rb', line 32

def initialize(file)
  @file = file
end

Instance Method Details

#fetchObject



40
41
42
43
44
45
46
47
48
# File 'lib/zold/txns.rb', line 40

def fetch
  raise "Wallet file '#{@file}' is absent" unless File.exist?(@file)
  lines = IO.read(@file).split(/\n/)
  raise "Not enough lines in #{@file}, just #{lines.count}" if lines.count < 4
  lines.drop(5)
    .each_with_index
    .map { |line, i| Txn.parse(line, i + 6) }
    .sort
end

#flushObject



36
37
38
# File 'lib/zold/txns.rb', line 36

def flush
  # nothing
end