Class: Psych::Handlers::Recorder
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Psych::Handler
|
|
Instance Chain:
self,
::Psych::Handler
|
|
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
Class Method Summary
- .new ⇒ Recorder constructor
Instance Attribute Summary
Instance Method Summary
::Psych::Handler
- Inherited
#alias | Called when an alias is found to |
#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. |
#event_location | Called before each event with line/column information. |
#scalar | Called when a scalar |
#start_document | Called when the document starts with the declared |
#start_mapping | Called when a map starts. |
#start_sequence | Called when a sequence is started. |
#start_stream | Called with |
Constructor Details
.new ⇒ Recorder
# File 'ext/psych/lib/psych/handlers/recorder.rb', line 28
def initialize @events = [] super end
Instance Attribute Details
#events (readonly)
[ GitHub ]# File 'ext/psych/lib/psych/handlers/recorder.rb', line 26
attr_reader :events