Class: C11n::Exporter::Yaml
- Inherits:
-
Object
- Object
- C11n::Exporter::Yaml
- Defined in:
- lib/c11n/exporter/yaml.rb
Instance Method Summary collapse
- #export(translations, locale) ⇒ Object
- #file ⇒ Object
-
#initialize(options = {}) ⇒ Yaml
constructor
A new instance of Yaml.
- #path_for(locale) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Yaml
Returns a new instance of Yaml.
6 7 8 9 |
# File 'lib/c11n/exporter/yaml.rb', line 6 def initialize( = {}) @base_path = [:base_path] @path = [:path] unless @base_path end |
Instance Method Details
#export(translations, locale) ⇒ Object
19 20 21 22 23 |
# File 'lib/c11n/exporter/yaml.rb', line 19 def export(translations, locale) deserialized_translations = C11n::Conversion::ComposedKeyDeserializer.new(translations.translations_for(locale)).deserialize file.print(YAML.dump(locale => deserialized_translations)) file.close end |
#file ⇒ Object
15 16 17 |
# File 'lib/c11n/exporter/yaml.rb', line 15 def file @file ||= File.new(@path, 'w') end |
#path_for(locale) ⇒ Object
11 12 13 |
# File 'lib/c11n/exporter/yaml.rb', line 11 def path_for(locale) @path || "#{@base_path}/#{locale}.yml" end |