Class: GdocTransReader
- Inherits:
-
Object
- Object
- GdocTransReader
- Defined in:
- lib/transync/gdoc_trans/gdoc_trans_reader.rb
Instance Attribute Summary collapse
-
#worksheet ⇒ Object
readonly
Returns the value of attribute worksheet.
Instance Method Summary collapse
-
#initialize(file) ⇒ GdocTransReader
constructor
file represents tab in spreadsheet.
- #translations(language) ⇒ Object
Constructor Details
#initialize(file) ⇒ GdocTransReader
file represents tab in spreadsheet
8 9 10 11 |
# File 'lib/transync/gdoc_trans/gdoc_trans_reader.rb', line 8 def initialize(file) @worksheet = TransyncConfig.worksheets.detect{ |w| w.title == file } abort("\u{2717} '#{file}' tab is not defined in GDoc".colorize(:red)) if @worksheet.nil? end |
Instance Attribute Details
#worksheet ⇒ Object (readonly)
Returns the value of attribute worksheet.
5 6 7 |
# File 'lib/transync/gdoc_trans/gdoc_trans_reader.rb', line 5 def worksheet @worksheet end |
Instance Method Details
#translations(language) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/transync/gdoc_trans/gdoc_trans_reader.rb', line 13 def translations(language) trans_hash = { file: @worksheet.title, language: language, translations: {} } key_column = TransyncConfig::WORKSHEET_COLUMNS[:key] language_column = TransyncConfig::WORKSHEET_COLUMNS[language.to_sym] (TransyncConfig::START_ROW..@worksheet.num_rows).to_a.each do |row| key = @worksheet[row, key_column] value = @worksheet[row, language_column] trans_hash[:translations][key] = value end trans_hash end |