Class: Psych::Visitors::Visitor

Inherits:
Object
  • Object
show all
Defined in:
lib/psych/visitors/visitor.rb,
ext/psych/to_ruby.c,
ext/psych/yaml_tree.c

Direct Known Subclasses

Emitter, ToRuby, YAMLTree

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVisitor

Returns a new instance of Visitor.



8
9
10
11
# File 'lib/psych/visitors/visitor.rb', line 8

def initialize
  @started  = false
  @finished = false
end

Instance Attribute Details

#finishedObject (readonly) Also known as: finished?

Returns the value of attribute finished.



4
5
6
# File 'lib/psych/visitors/visitor.rb', line 4

def finished
  @finished
end

#startedObject (readonly) Also known as: started?

Returns the value of attribute started.



4
5
6
# File 'lib/psych/visitors/visitor.rb', line 4

def started
  @started
end

Instance Method Details

#accept(target) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/psych/visitors/visitor.rb', line 13

def accept target
  case target
  when Psych::Nodes::Scalar   then visit_Psych_Nodes_Scalar target
  when Psych::Nodes::Mapping  then visit_Psych_Nodes_Mapping target
  when Psych::Nodes::Sequence then visit_Psych_Nodes_Sequence target
  when Psych::Nodes::Alias    then visit_Psych_Nodes_Alias target
  when Psych::Nodes::Document then visit_Psych_Nodes_Document target
  when Psych::Nodes::Stream   then visit_Psych_Nodes_Stream target
  else
    raise "Can't handle #{target}"
  end
end