Class: Toptranslation::Resource::Project
- Inherits:
-
Object
- Object
- Toptranslation::Resource::Project
- Defined in:
- lib/toptranslation/resource/project.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#locales ⇒ Object
readonly
Returns the value of attribute locales.
-
#name ⇒ Object
Returns the value of attribute name.
-
#source_locale ⇒ Object
readonly
Returns the value of attribute source_locale.
Instance Method Summary collapse
- #documents(options = {}) ⇒ Object
-
#initialize(connection, options = {}) ⇒ Project
constructor
A new instance of Project.
- #save ⇒ Object
- #strings ⇒ Object
- #upload_document(filepath, locale_code, options = {}, &block) ⇒ Object
Constructor Details
#initialize(connection, options = {}) ⇒ Project
Returns a new instance of Project.
6 7 8 9 10 11 |
# File 'lib/toptranslation/resource/project.rb', line 6 def initialize(connection, = {}) @connection = connection @options = update_from_response() end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/toptranslation/resource/project.rb', line 3 def created_at @created_at end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/toptranslation/resource/project.rb', line 3 def identifier @identifier end |
#locales ⇒ Object (readonly)
Returns the value of attribute locales.
3 4 5 |
# File 'lib/toptranslation/resource/project.rb', line 3 def locales @locales end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/toptranslation/resource/project.rb', line 4 def name @name end |
#source_locale ⇒ Object (readonly)
Returns the value of attribute source_locale.
3 4 5 |
# File 'lib/toptranslation/resource/project.rb', line 3 def source_locale @source_locale end |
Instance Method Details
#documents(options = {}) ⇒ Object
31 32 33 34 |
# File 'lib/toptranslation/resource/project.rb', line 31 def documents( = {}) .merge!(project_identifier: @identifier) ProjectDocumentList.new(@connection, ) end |
#save ⇒ Object
40 41 42 43 |
# File 'lib/toptranslation/resource/project.rb', line 40 def save response = @identifier ? update_remote_project : create_remote_project update_and_return_from_response(response) end |
#strings ⇒ Object
36 37 38 |
# File 'lib/toptranslation/resource/project.rb', line 36 def strings StringList.new(@connection, project_identifier: @identifier) end |
#upload_document(filepath, locale_code, options = {}, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/toptranslation/resource/project.rb', line 13 def upload_document(filepath, locale_code, = {}, &block) upload = Upload.new(@connection).upload(filepath, &block) attr_hash = { document_store_id: upload.document_store_id, document_token: upload.document_token, locale_code: locale_code, sha1: upload.sha1 } attr_hash[:path] = [:path] if [:path] attr_hash[:name] = [:name] if [:name] response = @connection.post("/projects/#{@identifier}/documents", attr_hash) Document.new(@connection, response) end |