Class: Translatomatic::Converter
- Inherits:
-
Object
- Object
- Translatomatic::Converter
- Includes:
- Util
- 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 27 28 29 |
# File 'lib/translatomatic/converter.rb', line 13 def convert(source, target) source_file = load_file(source) target_file = load_file(target) raise t('file.not_found', file: source) unless source_file.path.file? if source_file.type == target_file.type # if same file type, modify source. # this retains internal structure target_file = source_file else # different file type, copy properties from source file to target target_file.properties = source_file.properties end target_file.save(Pathname.new(target), @options) target_file end |