Class: Yamlt::Writer
- Inherits:
-
Object
- Object
- Yamlt::Writer
- Defined in:
- lib/yamlt/writer.rb
Instance Method Summary collapse
-
#initialize(state, loader, opts = {from: "en", to: "ru"}, callback = -> (old_value, path, from_l, to_l) { old_value }) ⇒ Writer
constructor
A new instance of Writer.
- #write(stream) ⇒ Object
Constructor Details
#initialize(state, loader, opts = {from: "en", to: "ru"}, callback = -> (old_value, path, from_l, to_l) { old_value }) ⇒ Writer
Returns a new instance of Writer.
8 9 10 11 12 13 14 15 |
# File 'lib/yamlt/writer.rb', line 8 def initialize(state, loader, opts = {from: "en", to: "ru"}, callback = -> (old_value, path, from_l, to_l) { old_value } ) @state = state @loader = loader @opts = opts @callback = callback end |
Instance Method Details
#write(stream) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/yamlt/writer.rb', line 17 def write(stream) @state.lines.each do |line| unless line.value stream.write(line.as_text) else stream.write(format_line(line)) end end end |