Class: WorldDb::Reader

Inherits:
ReaderBase show all
Defined in:
lib/worlddb/reader_file.rb

Instance Method Summary collapse

Methods inherited from ReaderBase

#load, #load_codes, #load_continent_defs, #load_continent_refs, #load_regions_xxx, #load_setup, #skip_tags?, #strict?

Methods included from Matcher

#match_cities_for_country, #match_countries_for_continent, #match_regions_abbr_for_country, #match_regions_for_country, #match_regions_iso_for_country, #match_regions_nuts_for_country, #match_xxx_for_country, #match_xxx_for_country_n_region

Constructor Details

#initialize(include_path, opts = {}) ⇒ Reader

Returns a new instance of Reader.



7
8
9
10
11
# File 'lib/worlddb/reader_file.rb', line 7

def initialize( include_path, opts={} )
  super( opts )

  @include_path = include_path
end

Instance Method Details

#create_city_reader(name, more_attribs = {}) ⇒ Object



50
51
52
53
54
55
# File 'lib/worlddb/reader_file.rb', line 50

def create_city_reader( name, more_attribs={} )
  path = "#{@include_path}/#{name}.txt"
  logger.info "parsing data (city) '#{name}' (#{path})..."

  CityReader.from_file( path, more_attribs )
end

#create_country_reader(name, more_attribs = {}) ⇒ Object



36
37
38
39
40
41
# File 'lib/worlddb/reader_file.rb', line 36

def create_country_reader( name, more_attribs={} )
  path = "#{@include_path}/#{name}.txt"
  logger.info "parsing data (country) '#{name}' (#{path})..."

  CountryReader.from_file( path, more_attribs )
end

#create_fixture_reader(name) ⇒ Object



14
15
16
17
18
19
# File 'lib/worlddb/reader_file.rb', line 14

def create_fixture_reader( name )
  path = "#{@include_path}/#{name}.txt"
  logger.info "parsing data (setup) '#{name}' (#{path})..."

  FixtureReader.from_file( path )
end

#create_hash_reader(name) ⇒ Object



58
59
60
61
62
63
# File 'lib/worlddb/reader_file.rb', line 58

def create_hash_reader( name )
  path = "#{@include_path}/#{name}.yml"
  logger.info "parsing data (hash) '#{name}' (#{path})..."

  HashReader.from_file( path )
end

#create_lang_reader(name) ⇒ Object



21
22
23
24
25
26
# File 'lib/worlddb/reader_file.rb', line 21

def create_lang_reader( name )
  path = "#{@include_path}/#{name}.yml"   ## hash reader - use .yml??
  logger.info "parsing data (lang) '#{name}' (#{path})..."

  LangReader.from_file( path )
end

#create_line_reader(name) ⇒ Object



72
73
74
75
76
77
# File 'lib/worlddb/reader_file.rb', line 72

def create_line_reader( name )
  path = "#{@include_path}/#{name}.txt"
  logger.info "parsing data (line) '#{name}' (#{path})..."

  LineReader.from_file( path )
end

#create_region_reader(name, more_attribs = {}) ⇒ Object



43
44
45
46
47
48
# File 'lib/worlddb/reader_file.rb', line 43

def create_region_reader( name, more_attribs={} )
  path = "#{@include_path}/#{name}.txt"
  logger.info "parsing data (region) '#{name}' (#{path})..."

  RegionReader.from_file( path, more_attribs )
end

#create_usage_reader(name) ⇒ Object



28
29
30
31
32
33
# File 'lib/worlddb/reader_file.rb', line 28

def create_usage_reader( name )
  path = "#{@include_path}/#{name}.yml"   ## hash reader - use .yml??
  logger.info "parsing data (usage) '#{name}' (#{path})..."

  UsageReader.from_file( path )
end

#create_values_reader(name, more_attribs = {}) ⇒ Object



65
66
67
68
69
70
# File 'lib/worlddb/reader_file.rb', line 65

def create_values_reader( name, more_attribs={} )
  path = "#{@include_path}/#{name}.txt"
  logger.info "parsing data (values) '#{name}' (#{path})..."

  ValuesReader.from_file( path, more_attribs )
end