Class: WorldDb::LangReader
- Inherits:
-
ReaderBaseWithOpts
- Object
- ReaderBaseWithOpts
- WorldDb::LangReader
- Defined in:
- lib/worlddb/readers/lang.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 32 33 34 35 36 37 38 39 |
# File 'lib/worlddb/readers/lang.rb', line 7 def read reader = HashReader.from_string( @text ) reader.each do |key, value| ### fix: ## move to Lang.read() for (re)use logger.debug "adding lang >>#{key}<< >>#{value}<<..." lang_key = key.strip lang_title = value.strip lang_attribs = {} ## check if it exists lang = Lang.find_by_key( lang_key ) if lang.present? logger.debug "update lang #{lang.id}-#{lang.key}:" else logger.debug "create lang:" lang = Lang.new lang_attribs[ :key ] = lang_key end lang_attribs[ :title ] = lang_title logger.debug lang_attribs.to_json lang.update_attributes!( lang_attribs ) end # each key,value end |