Class: WorldDb::UsageReader
- Inherits:
-
ReaderBaseWithOpts
- Object
- ReaderBaseWithOpts
- WorldDb::UsageReader
- Defined in:
- lib/worlddb/readers/usage.rb
Instance Method Summary collapse
Methods inherited from ReaderBaseWithOpts
from_file, from_string, from_zip, #initialize, #skip_tags?, #strict?
Methods included from TextUtils::ValueHelper
#is_state?, #match_city, #match_country, #match_metro, #match_metro_flag, #match_metro_pop, #match_state_for_country, #match_supra, #match_supra_flag
Constructor Details
This class inherits a constructor from WorldDb::ReaderBaseWithOpts
Instance Method Details
#read ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/worlddb/readers/usage.rb', line 7 def read reader = HashReader.from_string( @text ) reader.each do |key, value| ### fix: ## move to Usage.read() for (re)use logger.debug " adding langs >>#{value}<<to country >>#{key}<<" country = Country.find_by_key!( key ) lang_keys = value.split(',') lang_keys.each do |lang_key| ### remove (optional comment) from key (e.g. carribean (islands)) lang_key = lang_key.gsub( /\(.+\)/, '' ) ## remove leading n trailing space lang_key = lang_key.strip lang = Lang.find_by_key!( lang_key ) Usage.create!( country_id: country.id, lang_id: lang.id, official: true, minor: false ) end end end |