Class: Txdb::Downloader
- Inherits:
-
Object
- Object
- Txdb::Downloader
- Defined in:
- lib/txdb/downloader.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Class Method Summary collapse
Instance Method Summary collapse
- #download(locale) ⇒ Object
- #download_resource(tx_resource, table, locale) ⇒ Object
- #download_table(table, locale) ⇒ Object
-
#initialize(database) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(database) ⇒ Downloader
Returns a new instance of Downloader.
13 14 15 |
# File 'lib/txdb/downloader.rb', line 13 def initialize(database) @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
11 12 13 |
# File 'lib/txdb/downloader.rb', line 11 def database @database end |
Class Method Details
.download(database, locale) ⇒ Object
6 7 8 |
# File 'lib/txdb/downloader.rb', line 6 def download(database, locale) new(database).download(locale) end |
Instance Method Details
#download(locale) ⇒ Object
17 18 19 20 21 |
# File 'lib/txdb/downloader.rb', line 17 def download(locale) database.tables.each do |table| download_table(table, locale) end end |
#download_resource(tx_resource, table, locale) ⇒ Object
30 31 32 33 34 |
# File 'lib/txdb/downloader.rb', line 30 def download_resource(tx_resource, table, locale) content = transifex_api.download(tx_resource, locale) resource = Txdb::TxResource.new(tx_resource, content) table.write_content(resource, locale) end |
#download_table(table, locale) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/txdb/downloader.rb', line 23 def download_table(table, locale) resources.each do |tx_resource| next unless process_resource?(tx_resource, table) download_resource(tx_resource, table, locale) end end |