Class: Transifex::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/transifex/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transifex_data) ⇒ Project

Returns a new instance of Project.



5
6
7
8
9
10
# File 'lib/transifex/project.rb', line 5

def initialize(transifex_data)
  @name = transifex_data[:name]
  @description = transifex_data[:description]
  @source_language_code = transifex_data[:source_langauge_code]
  @slug = transifex_data[:slug]
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/transifex/project.rb', line 3

def client
  @client
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/transifex/project.rb', line 3

def description
  @description
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/transifex/project.rb', line 3

def name
  @name
end

#slugObject

Returns the value of attribute slug.



3
4
5
# File 'lib/transifex/project.rb', line 3

def slug
  @slug
end

#source_language_codeObject

Returns the value of attribute source_language_code.



3
4
5
# File 'lib/transifex/project.rb', line 3

def source_language_code
  @source_language_code
end

Instance Method Details

#detailsObject



12
13
14
# File 'lib/transifex/project.rb', line 12

def details
  @details || details!
end

#details!Object



16
17
18
# File 'lib/transifex/project.rb', line 16

def details!
  @details = client.get("/project/#{@slug}?details")
end

#languagesObject



31
32
33
34
35
# File 'lib/transifex/project.rb', line 31

def languages
  client.get("/project/#{@slug}/languages/").map do |language|
    Transifex::Language.new(@slug, language).tap {|r| r.client = client }
  end
end

#resource(resource_slug) ⇒ Object



26
27
28
29
# File 'lib/transifex/project.rb', line 26

def resource(resource_slug)
  resource = client.get("/project/#{@slug}/resource/#{resource_slug}")
  Transifex::Resource.new(@slug, resource).tap {|r| r.client = client }
end

#resourcesObject



20
21
22
23
24
# File 'lib/transifex/project.rb', line 20

def resources
  client.get("/project/#{@slug}/resources/").map do |resource|
    Transifex::Resource.new(@slug, resource).tap {|r| r.client = client }
  end
end