class Transifex::Project

Attributes

account[RW]
description[RW]
main_language[RW]
name[RW]
slug[RW]

Public Class Methods

new(project_data, account) click to toggle source
# 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

Public Instance Methods

languages() click to toggle source
# File lib/transifex/project.rb, line 22
def languages
  @languages ||= account.get("#{base_path}/languages/").map(&:language_code)
end
resource(resource_slug) click to toggle source
# 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() click to toggle source
# File lib/transifex/project.rb, line 12
def resources
   @resources ||= initializ_resources(account.get("#{base_path}/resources/"))
end
translation(resource, language_code) click to toggle source
# 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

Private Instance Methods

base_path() click to toggle source
# File lib/transifex/project.rb, line 38
def base_path
  "/project/#{slug}"
end
initializ_resources(resource_data_array) click to toggle source
# File lib/transifex/project.rb, line 42
def initializ_resources(resource_data_array)
  resource_data_array.map do |resource_data|
    Resource.new(resource_data, self)
  end
end
resource_path(resource_slug) click to toggle source
# File lib/transifex/project.rb, line 34
def resource_path(resource_slug)
  "#{base_path}/resource/#{resource_slug}/"
end