Class: YPS::Handler

Inherits:
Psych::Handlers::DocumentStream
  • Object
show all
Defined in:
lib/yps/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filename ⇒ Object

Returns the value of attribute filename.



7
8
9
# File 'lib/yps/parser.rb', line 7

def filename
  @filename
end

Instance Method Details

#scalar ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/yps/parser.rb', line 9

def scalar(...)
  node = super

  # The given value was added to @last.children as a mappking key inside super.
  # Therefore, it is a mappking key if size of @last.children is odd.
  if @last.mapping? && @last.children.size.odd?
    node.mapping_key
  end

  node
end

#set_start_location(node) ⇒ Object

rubocop:disable Naming/AccessorMethodName



21
22
23
24
# File 'lib/yps/parser.rb', line 21

def set_start_location(node) # rubocop:disable Naming/AccessorMethodName
  super
  node.filename = filename
end