Class: BeerDb::Reader
- Inherits:
-
ReaderBase
- Object
- ReaderBase
- BeerDb::Reader
- Defined in:
- lib/beerdb/reader_file.rb
Overview
todo: “old” classic reader - rename to FileReader ?? why? why not?
Instance Method Summary collapse
- #create_beers_reader(name, more_attribs = {}) ⇒ Object
- #create_breweries_reader(name, more_attribs = {}) ⇒ Object
- #create_fixture_reader(name) ⇒ Object
-
#initialize(include_path, opts = {}) ⇒ Reader
constructor
A new instance of Reader.
Methods inherited from ReaderBase
#load, #load_beers_for_country, #load_beers_for_country_n_state, #load_beers_worker, #load_breweries_for_country, #load_breweries_for_country_n_state, #load_breweries_worker, #load_setup
Methods included from Matcher
#match_beers_for_country, #match_beers_for_country_n_state, #match_breweries_for_country, #match_breweries_for_country_n_state, #match_brewpubs_for_country, #match_brewpubs_for_country_n_state
Constructor Details
#initialize(include_path, opts = {}) ⇒ Reader
Returns a new instance of Reader.
9 10 11 |
# File 'lib/beerdb/reader_file.rb', line 9 def initialize( include_path, opts = {} ) @include_path = include_path end |
Instance Method Details
#create_beers_reader(name, more_attribs = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/beerdb/reader_file.rb', line 21 def create_beers_reader( name, more_attribs={} ) real_name = name_to_real_name( name ) path = "#{@include_path}/#{real_name}.txt" logger.info "parsing data (beers) '#{name}' (#{path})..." BeerReader.from_file( path, more_attribs ) end |
#create_breweries_reader(name, more_attribs = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/beerdb/reader_file.rb', line 31 def create_breweries_reader( name, more_attribs={} ) real_name = name_to_real_name( name ) path = "#{@include_path}/#{real_name}.txt" logger.info "parsing data (breweries) '#{name}' (#{path})..." if name =~ /\(m\)/ # check for (m) mid-size/medium marker -todo- use $?? must be last? more_attribs[ :prod_m ] = true elsif name =~ /\(l\)/ # check for (l) large marker - todo - use $?? must be last? more_attribs[ :prod_l ] = true else ## no marker; do nothing end BreweryReader.from_file( path, more_attribs ) end |
#create_fixture_reader(name) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/beerdb/reader_file.rb', line 13 def create_fixture_reader( name ) path = "#{@include_path}/#{name}.txt" logger.info "parsing data (setup) '#{name}' (#{path})..." FixtureReader.from_file( path ) end |