Class: Transifex::ResourceComponents::Content

Inherits:
Object
  • Object
show all
Includes:
CrudRequests::Fetch, CrudRequests::Update
Defined in:
lib/transifex/resource_components/content.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, resource_slug) ⇒ Content

Returns a new instance of Content.



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

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

Instance Attribute Details

#project_slugObject

Returns the value of attribute project_slug.



7
8
9
# File 'lib/transifex/resource_components/content.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/content.rb', line 7

def resource_slug
  @resource_slug
end

Class Method Details

.authorsObject



15
16
17
# File 'lib/transifex/resource_components/content.rb', line 15

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

Instance Method Details

#fetch_with_file(path_to_file = nil) ⇒ Object



18
19
20
21
22
23
# File 'lib/transifex/resource_components/content.rb', line 18

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

#update(params = {}, options = {}) ⇒ Object

Raises:



25
26
27
28
29
# File 'lib/transifex/resource_components/content.rb', line 25

def update(params = {}, options = {})
  resource_i18n_type = Transifex::Resource.new(@project_slug, @resource_slug).fetch
  raise Transifex::Error.new("You must use the mimetype #{resource_i18n_type["i18n_type"]} to upload a new resource file") if !check_i18n_type_concordance?(resource_i18n_type["i18n_type"], params[:i18n_type]) 
  super
end