Class: Yaml::Converter::StreamingEmitter
- Inherits:
-
Object
- Object
- Yaml::Converter::StreamingEmitter
- Defined in:
- lib/yaml/converter/streaming_emitter.rb
Overview
StreamingEmitter converts YAML to Markdown incrementally.
It mirrors MarkdownEmitter + StateMachine behavior while writing to an IO target.
Intended for very large inputs to avoid building all output in memory.
Constant Summary collapse
- START_YAML =
"```yaml"- END_YAML =
"```"
Instance Method Summary collapse
-
#emit_file(input_path) ⇒ void
Stream-convert an input file path to the configured IO.
-
#initialize(options, io) ⇒ StreamingEmitter
constructor
A new instance of StreamingEmitter.
-
#set_validation_status(status) ⇒ void
Set the validation status used when injecting the validation status line.
Constructor Details
#initialize(options, io) ⇒ StreamingEmitter
Returns a new instance of StreamingEmitter.
17 18 19 20 21 22 23 |
# File 'lib/yaml/converter/streaming_emitter.rb', line 17 def initialize(, io) @options = @io = io @validation_status = :ok @state = :text @_last_line_blank = nil end |
Instance Method Details
#emit_file(input_path) ⇒ void
This method returns an undefined value.
Stream-convert an input file path to the configured IO.
35 36 37 38 39 40 41 42 43 |
# File 'lib/yaml/converter/streaming_emitter.rb', line 35 def emit_file(input_path) File.open(input_path, "r") do |f| f.each_line do |raw| emit_line(raw) end end close_yaml if @options[:emit_footer] end |
#set_validation_status(status) ⇒ void
This method returns an undefined value.
Set the validation status used when injecting the validation status line.
28 29 30 |
# File 'lib/yaml/converter/streaming_emitter.rb', line 28 def set_validation_status(status) @validation_status = status end |