Class: Transifex::Resource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_slug, transifex_data) ⇒ Resource

Returns a new instance of Resource.



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

def initialize(project_slug, transifex_data)
  @project_slug = project_slug
  @name = transifex_data[:name]
  @category = transifex_data[:category]
  @i18n_type = transifex_data[:i18n_type]
  @source_language_code = transifex_data[:source_language_code]
  @slug = transifex_data[:slug]
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



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

def category
  @category
end

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#i18n_typeObject

Returns the value of attribute i18n_type.



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

def i18n_type
  @i18n_type
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#slugObject

Returns the value of attribute slug.



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

def slug
  @slug
end

#source_language_codeObject

Returns the value of attribute source_language_code.



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

def source_language_code
  @source_language_code
end

Instance Method Details

#contentObject



14
15
16
# File 'lib/transifex/resource.rb', line 14

def content
  client.get("/project/#{@project_slug}/resource/#{@slug}/content/")
end

#stats(lang) ⇒ Object



22
23
24
25
# File 'lib/transifex/resource.rb', line 22

def stats(lang)
  stats = client.get("/project/#{@project_slug}/resource/#{@slug}/stats/#{lang}")
  Transifex::Stats.new(stats).tap {|r| r.client = client }
end

#translation(lang) ⇒ Object



18
19
20
# File 'lib/transifex/resource.rb', line 18

def translation(lang)
  client.get("/project/#{@project_slug}/resource/#{@slug}/translation/#{lang}/")
end