Class: Transifex::ResourceComponents::Translation

Inherits:
Object
  • Object
show all
Includes:
CrudRequests::Fetch, CrudRequests::Update
Defined in:
lib/transifex/resource_components/translation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CrudRequests::Update

included

Methods included from CrudRequests::Fetch

included

Constructor Details

#initialize(project_slug = nil, resource_slug = nil, translation_slug = nil) ⇒ Translation

Returns a new instance of Translation.



9
10
11
12
13
14
15
16
# File 'lib/transifex/resource_components/translation.rb', line 9

def initialize(project_slug = nil, resource_slug = nil, translation_slug = nil)
  raise MissingParametersError.new(["project_slug"]) if project_slug.nil?
  raise MissingParametersError.new(["resource_slug"]) if resource_slug.nil?
  raise MissingParametersError.new(["translation_slug"]) if translation_slug.nil?
  @project_slug = project_slug
  @resource_slug = resource_slug
  @translation_slug = translation_slug
end

Instance Attribute Details

#project_slugObject

Returns the value of attribute project_slug.



7
8
9
# File 'lib/transifex/resource_components/translation.rb', line 7

def project_slug
  @project_slug
end

#resource_slugObject

Returns the value of attribute resource_slug.



7
8
9
# File 'lib/transifex/resource_components/translation.rb', line 7

def resource_slug
  @resource_slug
end

#translation_slugObject

Returns the value of attribute translation_slug.



7
8
9
# File 'lib/transifex/resource_components/translation.rb', line 7

def translation_slug
  @translation_slug
end

Class Method Details

.authorsObject



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

def self.authors
  [:project, :resource]      
end

Instance Method Details

#fetch(options = {}) ⇒ Object



22
23
24
# File 'lib/transifex/resource_components/translation.rb', line 22

def fetch(options = {})
  super
end

#fetch_with_file(options = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/transifex/resource_components/translation.rb', line 26

def fetch_with_file(options = {})
  raise MissingParametersError.new(["path_to_file"]) if options[:path_to_file].nil?
  path_to_file = options.delete(:path_to_file)
  options[:file] = true
  file_body = fetch(options)         
  write_to_file(path_to_file, file_body)  
end

#string(key = nil, context = "") ⇒ Object



38
39
40
41
42
# File 'lib/transifex/resource_components/translation.rb', line 38

def string(key = nil , context = "")
  raise MissingParametersError.new(["key"]) if key.nil?
  raise MissingParametersError.new(["context"]) if context.nil?        
  Transifex::ResourceComponents::TranslationComponents::String.new(@project_slug, @resource_slug, @translation_slug, key, context)  
end

#stringsObject



34
35
36
# File 'lib/transifex/resource_components/translation.rb', line 34

def strings
  Transifex::ResourceComponents::TranslationComponents::Strings.new(@project_slug, @resource_slug, @translation_slug)  
end