Class: Psych::SimpleHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/psych/simple.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ SimpleHandler

Returns a new instance of SimpleHandler.



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

def initialize(options = nil)
  @symbolize_names = options && options[:symbolize_names]
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



24
25
26
# File 'lib/psych/simple.rb', line 24

def document
  @document
end

Instance Method Details

#alias(anchor) ⇒ Object



76
77
78
# File 'lib/psych/simple.rb', line 76

def alias(anchor)
  raise
end

#emptyObject



80
81
82
# File 'lib/psych/simple.rb', line 80

def empty
  raise
end

#end_document(implicit) ⇒ Object



43
44
45
# File 'lib/psych/simple.rb', line 43

def end_document(implicit)
  @document = @stack.pop.last
end

#end_mappingObject



52
53
54
55
56
57
58
59
# File 'lib/psych/simple.rb', line 52

def end_mapping
  mapping = Hash.new
  @stack.pop.each_slice(2) do |name, value|
    name = name.to_sym if @symbolize_names
    mapping[name] = value
  end
  @stack.last << mapping
end

#end_sequenceObject



66
67
68
69
# File 'lib/psych/simple.rb', line 66

def end_sequence
  sequence = @stack.pop
  @stack.last << sequence
end

#end_streamObject



34
35
36
# File 'lib/psych/simple.rb', line 34

def end_stream
  raise unless @stack.empty?
end

#scalar(value, anchor, tag, plain, quoted, style) ⇒ Object



71
72
73
74
# File 'lib/psych/simple.rb', line 71

def scalar(value, anchor, tag, plain, quoted, style)
  raise if anchor or tag
  @stack.last << value
end

#start_document(version, tag_directives, implicit) ⇒ Object



38
39
40
41
# File 'lib/psych/simple.rb', line 38

def start_document(version, tag_directives, implicit)
  raise unless tag_directives.empty?
  @stack.push Array.new
end

#start_mapping(anchor, tag, implicit, style) ⇒ Object



47
48
49
50
# File 'lib/psych/simple.rb', line 47

def start_mapping(anchor, tag, implicit, style)
  raise if anchor or tag
  @stack.push(Array.new)
end

#start_sequence(anchor, tag, implicit, style) ⇒ Object



61
62
63
64
# File 'lib/psych/simple.rb', line 61

def start_sequence(anchor, tag, implicit, style)
  raise if anchor or tag
  @stack.push(Array.new)
end

#start_stream(encoding) ⇒ Object



30
31
32
# File 'lib/psych/simple.rb', line 30

def start_stream(encoding)
  @stack = Array.new
end