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

new(*stylers,deref_aliases: false,**options,&block) click to toggle source

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

Calls superclass method
# 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

end_document(implicit_end=!streaming?) click to toggle source

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
start_document(version,tag_directives,implicit) click to toggle source

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