class Psychgus::StyledDocumentStream
Use this wherever Psych::Handlers::DocumentStream would have been used, to enable styling.
@author Jonathan Bradley Whited @since 1.0.0
@see Psychgus.parse_stream
Psychgus.parse_stream
@see Psych::Handlers::DocumentStream
Public Class Methods
Initialize this class with {Styler}(s) and a block.
@param stylers [Styler] {Styler}(s) to use for styling this DocumentStream @param deref_aliases [true,false] whether to dereference aliases; output the actual value
instead of the alias
@param block [Proc] a block to call in {#end_document} to denote a new YAML document
# File lib/psychgus/styled_document_stream.rb, line 33 def initialize(*stylers,deref_aliases: false,**options,&block) super(*stylers,deref_aliases: deref_aliases,**options) @block = block end
Public Instance Methods
This mimics the behavior of Psych::Handlers::DocumentStream#end_document.
@see Psych::Handlers::DocumentStream#end_document
# File lib/psychgus/styled_document_stream.rb, line 42 def end_document(implicit_end=!streaming?) @last.implicit_end = implicit_end @block.call(pop) end
This mimics the behavior of Psych::Handlers::DocumentStream#start_document.
@see Psych::Handlers::DocumentStream#start_document
# File lib/psychgus/styled_document_stream.rb, line 50 def start_document(version,tag_directives,implicit) node = Psych::Nodes::Document.new(version,tag_directives,implicit) push(node) end