Class: Psychgus::StyledDocumentStream
- Inherits:
-
StyledTreeBuilder
- Object
- Psych::TreeBuilder
- StyledTreeBuilder
- Psychgus::StyledDocumentStream
- Defined in:
- lib/psychgus/styled_document_stream.rb
Overview
Use this wherever Psych::Handlers::DocumentStream would have been used, to enable styling.
Instance Attribute Summary
Attributes inherited from StyledTreeBuilder
#deref_aliases, #sniffer, #stylers
Instance Method Summary collapse
-
#end_document(implicit_end = !streaming?)) ⇒ Object
This mimics the behavior of Psych::Handlers::DocumentStream#end_document.
-
#initialize(*stylers, deref_aliases: false, **options, &block) ⇒ StyledDocumentStream
constructor
Initialize this class with Styler(s) and a block.
-
#start_document(version, tag_directives, implicit) ⇒ Object
This mimics the behavior of Psych::Handlers::DocumentStream#start_document.
Methods inherited from StyledTreeBuilder
#add_styler, #alias, #end_mapping, #end_sequence, #end_stream, #insert_styler, #pop_styler, #remove_styler, #remove_styler_at, #scalar, #start_mapping, #start_sequence, #start_stream
Constructor Details
#initialize(*stylers, deref_aliases: false, **options, &block) ⇒ StyledDocumentStream
Initialize this class with Psychgus::Styler(s) and a block.
29 30 31 32 33 |
# File 'lib/psychgus/styled_document_stream.rb', line 29 def initialize(*stylers,deref_aliases: false,**,&block) super(*stylers,deref_aliases: deref_aliases,**) @block = block end |
Instance Method Details
#end_document(implicit_end = !streaming?)) ⇒ Object
This mimics the behavior of Psych::Handlers::DocumentStream#end_document.
38 39 40 41 |
# File 'lib/psychgus/styled_document_stream.rb', line 38 def end_document(implicit_end=!streaming?) @last.implicit_end = implicit_end @block.call(pop) end |
#start_document(version, tag_directives, implicit) ⇒ Object
This mimics the behavior of Psych::Handlers::DocumentStream#start_document.
46 47 48 49 |
# File 'lib/psychgus/styled_document_stream.rb', line 46 def start_document(version,tag_directives,implicit) node = Psych::Nodes::Document.new(version,tag_directives,implicit) push(node) end |