Class: Zold::Head

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

Overview

Head of the wallet.

Defined Under Namespace

Classes: CantParse

Instance Method Summary collapse

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

#fetchObject

Raises:



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

#flushObject



39
40
41
# File 'lib/zold/head.rb', line 39

def flush
  # nothing
end