123456789_123456789_123456789_123456789_123456789_

Class: Psych::Handlers::Recorder

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Psych::Handler
Defined in: ext/psych/lib/psych/handlers/recorder.rb

Overview

This handler will capture an event and record the event. Recorder events are available vial #events.

For example:

recorder = Psych::Handlers::Recorder.new
parser = Psych::Parser.new recorder
parser.parse '--- foo'

recorder.events # => [list of events]

# Replay the events

emitter = Psych::Emitter.new $stdout
recorder.events.each do |m, args|
  emitter.send m, *args
end

Constant Summary

::Psych::Handler - Inherited

EVENTS, OPTIONS

Class Method Summary

Instance Attribute Summary

::Psych::Handler - Inherited

#streaming?

Is this handler a streaming handler?

Instance Method Summary

::Psych::Handler - Inherited

#alias

Called when an alias is found to anchor.

#empty

Called when an empty event happens.

#end_document

Called with the document ends.

#end_mapping

Called when a map ends.

#end_sequence

Called when a sequence ends.

#end_stream

Called when the YAML stream ends.

#scalar

Called when a scalar value is found.

#start_document

Called when the document starts with the declared version, tag_directives, if the document is implicit.

#start_mapping

Called when a map starts.

#start_sequence

Called when a sequence is started.

#start_stream

Called with encoding when the YAML stream starts.

Constructor Details

.newRecorder

[ GitHub ]

  
# File 'ext/psych/lib/psych/handlers/recorder.rb', line 27

def initialize
  @events = []
  super
end

Instance Attribute Details

#events (readonly)

[ GitHub ]

  
# File 'ext/psych/lib/psych/handlers/recorder.rb', line 25

attr_reader :events