Class: Translatomatic::Converter
- Inherits:
-
Object
- Object
- Translatomatic::Converter
- Defined in:
- lib/translatomatic/converter.rb
Overview
Converts files from one format to another
Instance Method Summary collapse
-
#convert(source, target) ⇒ Translatomatic::ResourceFile
Convert a resource file from one format to another.
-
#initialize(options = {}) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(options = {}) ⇒ Converter
Returns a new instance of Converter.
4 5 6 |
# File 'lib/translatomatic/converter.rb', line 4 def initialize( = {}) @options = end |
Instance Method Details
#convert(source, target) ⇒ Translatomatic::ResourceFile
Convert a resource file from one format to another.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/translatomatic/converter.rb', line 13 def convert(source, target) source_path = Pathname.new(source.to_s) target_path = Pathname.new(target.to_s) raise t("file.not_found", file: source.to_s) unless source_path.file? raise t("file.directory", file: target.to_s) if target_path.directory? source_file = load_file(source_path) target_file = load_file(target_path) # copy properties from source file to target target_file.properties = source_file.properties target_file.save(target_path, @options) target_file end |