Class: Psych::Handlers::Recorder

Inherits:
Psych::Handler show all
Defined in:
lib/psych/handlers/recorder.rb

Overview

This handler will capture an event and record the event. Recorder events are available vial Psych::Handlers::Recorder#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

Constants inherited from Psych::Handler

Psych::Handler::EVENTS, Psych::Handler::OPTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Psych::Handler

#alias, #empty, #end_document, #end_mapping, #end_sequence, #end_stream, #scalar, #start_document, #start_mapping, #start_sequence, #start_stream, #streaming?

Constructor Details

#initializeRecorder

Returns a new instance of Recorder.



28
29
30
31
# File 'lib/psych/handlers/recorder.rb', line 28

def initialize
  @events = []
  super
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events



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

def events
  @events
end