Class: Transifex::Project
- Inherits:
-
Object
- Object
- Transifex::Project
- Defined in:
- lib/transifex/project.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#description ⇒ Object
Returns the value of attribute description.
-
#main_language ⇒ Object
Returns the value of attribute main_language.
-
#name ⇒ Object
Returns the value of attribute name.
-
#slug ⇒ Object
Returns the value of attribute slug.
Instance Method Summary collapse
-
#initialize(project_data, account) ⇒ Project
constructor
A new instance of Project.
- #languages ⇒ Object
- #resource(resource_slug) ⇒ Object
- #resources ⇒ Object
- #translation(resource, language_code) ⇒ Object
Constructor Details
#initialize(project_data, account) ⇒ Project
Returns a new instance of Project.
4 5 6 7 8 9 10 |
# File 'lib/transifex/project.rb', line 4 def initialize(project_data, account) @name = project_data.name @description = project_data.description @slug = project_data.slug @main_language = project_data.source_language_code @account = account end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
3 4 5 |
# File 'lib/transifex/project.rb', line 3 def account @account end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/transifex/project.rb', line 3 def description @description end |
#main_language ⇒ Object
Returns the value of attribute main_language.
3 4 5 |
# File 'lib/transifex/project.rb', line 3 def main_language @main_language end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/transifex/project.rb', line 3 def name @name end |
#slug ⇒ Object
Returns the value of attribute slug.
3 4 5 |
# File 'lib/transifex/project.rb', line 3 def slug @slug end |
Instance Method Details
#languages ⇒ Object
22 23 24 |
# File 'lib/transifex/project.rb', line 22 def languages @languages ||= account.get("#{base_path}/languages/").map(&:language_code) end |
#resource(resource_slug) ⇒ Object
16 17 18 19 20 |
# File 'lib/transifex/project.rb', line 16 def resource(resource_slug) resource_data = account.get(resource_path(resource_slug)) return if resource_data == 'Not Found' Resource.new(resource_data, self) end |
#resources ⇒ Object
12 13 14 |
# File 'lib/transifex/project.rb', line 12 def resources @resources ||= initializ_resources(account.get("#{base_path}/resources/")) end |
#translation(resource, language_code) ⇒ Object
26 27 28 29 30 |
# File 'lib/transifex/project.rb', line 26 def translation(resource, language_code) translation_data = account.get("#{resource_path(resource.slug)}translation/#{language_code}/") return if translation_data == 'Not Found' Translation.new(translation_data, resource) end |