Class: Zold::Txns
- Inherits:
-
Object
- Object
- Zold::Txns
- Defined in:
- lib/zold/txns.rb
Overview
A collection of transactions
Defined Under Namespace
Classes: Cached
Instance Method Summary collapse
- #fetch ⇒ Object
- #flush ⇒ Object
-
#initialize(file) ⇒ Txns
constructor
A new instance of Txns.
Constructor Details
#initialize(file) ⇒ Txns
Returns a new instance of Txns.
33 34 35 |
# File 'lib/zold/txns.rb', line 33 def initialize(file) @file = file end |
Instance Method Details
#fetch ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/zold/txns.rb', line 41 def fetch raise "Wallet file '#{@file}' is absent" unless File.exist?(@file) lines = AtomicFile.new(@file).read.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 |
#flush ⇒ Object
37 38 39 |
# File 'lib/zold/txns.rb', line 37 def flush # nothing end |