Class: HashReader

Inherits:
Object
  • Object
show all
Defined in:
lib/worlddb/readers/hash_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger = nil, path) ⇒ HashReader

Returns a new instance of HashReader.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/worlddb/readers/hash_reader.rb', line 6

def initialize( logger=nil, path )
  if logger.nil?
    @logger = Logger.new(STDOUT)
    @logger.level = Logger::INFO
  else
    @logger = logger
  end
  
  @path = path

  ## nb: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
  ## - see worlddb/utils.rb
  @hash = YAML.load( File.read_utf8( @path ))
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



21
22
23
# File 'lib/worlddb/readers/hash_reader.rb', line 21

def hash
  @hash
end

#loggerObject (readonly)

Returns the value of attribute logger.



21
22
23
# File 'lib/worlddb/readers/hash_reader.rb', line 21

def logger
  @logger
end