Class: SportDb::SeasonReader
- Inherits:
-
Object
- Object
- SportDb::SeasonReader
- Includes:
- LogUtils::Logging, Model
- Defined in:
- lib/sportdb/readers/season.rb
Constant Summary
Constants included from Model
Model::City, Model::Continent, Model::Country, Model::Prop, Model::Region
Instance Attribute Summary collapse
-
#include_path ⇒ Object
readonly
Returns the value of attribute include_path.
Instance Method Summary collapse
-
#initialize(include_path, opts = {}) ⇒ SeasonReader
constructor
A new instance of SeasonReader.
- #read(name, more_attribs = {}) ⇒ Object
Constructor Details
#initialize(include_path, opts = {}) ⇒ SeasonReader
Returns a new instance of SeasonReader.
18 19 20 |
# File 'lib/sportdb/readers/season.rb', line 18 def initialize( include_path, opts = {} ) @include_path = include_path end |
Instance Attribute Details
#include_path ⇒ Object (readonly)
Returns the value of attribute include_path.
15 16 17 |
# File 'lib/sportdb/readers/season.rb', line 15 def include_path @include_path end |
Instance Method Details
#read(name, more_attribs = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/sportdb/readers/season.rb', line 23 def read( name, more_attribs={} ) reader = LineReaderV2.new( name, include_path ) #### ## fix!!!!! ## use Season.create_or_update_from_hash or similar ## use Season.create_or_update_from_hash_reader?? or similar # move parsing code to model reader.each_line do |line| # for now assume single value logger.debug ">#{line}<" key = line logger.debug " find season key: #{key}" season = Season.find_by_key( key ) season_attribs = {} ## check if it exists if season.present? logger.debug "update season #{season.id}-#{season.key}:" else logger.debug "create season:" season = Season.new season_attribs[ :key ] = key end season_attribs[ :title ] = key # for now key n title are the same logger.debug season_attribs.to_json season.update_attributes!( season_attribs ) end # each line end |