class Transifex::ResourceComponents::Translation
Attributes
project_slug[RW]
resource_slug[RW]
translation_slug[RW]
Public Class Methods
new(project_slug = nil, resource_slug = nil, translation_slug = nil)
click to toggle source
# 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
Public Instance Methods
fetch(options = {})
click to toggle source
Calls superclass method
# File lib/transifex/resource_components/translation.rb, line 22 def fetch(options = {}) super end
fetch_with_file(options = {})
click to toggle source
# 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 = "")
click to toggle source
# 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
strings()
click to toggle source
# File lib/transifex/resource_components/translation.rb, line 34 def strings Transifex::ResourceComponents::TranslationComponents::Strings.new(@project_slug, @resource_slug, @translation_slug) end
Private Instance Methods
write_to_file(path_to_file, content)
click to toggle source
# File lib/transifex/resource_components/translation.rb, line 46 def write_to_file(path_to_file, content) case File.extname(path_to_file) when ".yml" # Needed to correct carriage return problems when writing the Api response in the file d = YAML::load(content) File.open(path_to_file, "w") { |file| file.write d.to_yaml } else File.open(path_to_file, "w") { |file| file.write content } end end