Class: Zold::Head
- Inherits:
-
Object
- Object
- Zold::Head
- Defined in:
- lib/zold/head.rb
Overview
Head of the wallet.
Defined Under Namespace
Classes: CantParse
Instance Method Summary collapse
- #fetch ⇒ Object
- #flush ⇒ Object
-
#initialize(file) ⇒ Head
constructor
A new instance of Head.
Constructor Details
#initialize(file) ⇒ Head
Returns a new instance of Head.
35 36 37 |
# File 'lib/zold/head.rb', line 35 def initialize(file) @file = file end |
Instance Method Details
#fetch ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/zold/head.rb', line 43 def fetch raise "Wallet file '#{@file}' is absent" unless File.exist?(@file) lines = [] File.open(@file) do |f| lines << f.readline.strip while lines.count < 4 && !f.eof? end raise CantParse, "Not enough lines in #{@file}, just #{lines.count}" if lines.count < 4 lines end |
#flush ⇒ Object
39 40 41 |
# File 'lib/zold/head.rb', line 39 def flush # nothing end |