Class: Yamlt::Updater
- Inherits:
-
Object
- Object
- Yamlt::Updater
- Defined in:
- lib/yamlt/updater.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(source, target, translator_class = Yamlt::Updater.translator_class) ⇒ Updater
constructor
A new instance of Updater.
- #rename_updated ⇒ Object
Constructor Details
#initialize(source, target, translator_class = Yamlt::Updater.translator_class) ⇒ Updater
Returns a new instance of Updater.
12 13 14 15 16 |
# File 'lib/yamlt/updater.rb', line 12 def initialize(source, target, translator_class = Yamlt::Updater.translator_class) @source = source @target = target @translator = translator_class.new(state.language, loader.language) end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
18 19 20 |
# File 'lib/yamlt/updater.rb', line 18 def target @target end |
Class Method Details
.translator_class ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/yamlt/updater.rb', line 34 def self.translator_class if defined?(::Yamlt::CustomTranslator) ::Yamlt::CustomTranslator else ::Yamlt::Translator end end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/yamlt/updater.rb', line 20 def call of = File.new(target_updated, "w") state.lines.each do |line| of.puts format_line(line) end of.close end |
#rename_updated ⇒ Object
30 31 32 |
# File 'lib/yamlt/updater.rb', line 30 def rename_updated File.rename(target_updated, target) end |