class Yamlook::Handler
Handler
for Psych::Parser
Attributes
found[R]
Public Class Methods
new(keys:, locales: [])
click to toggle source
Calls superclass method
# File lib/yamlook/handler.rb, line 10 def initialize(keys:, locales: []) super() @keys = keys @locales = locales @found = [] @iterations = [] @current_iteration = Iteration.new(active: true) end
Public Instance Methods
all_active?()
click to toggle source
# File lib/yamlook/handler.rb, line 62 def all_active? @iterations.any? && @iterations.all?(&:active) && @current_iteration.active end
current_keys()
click to toggle source
# File lib/yamlook/handler.rb, line 54 def current_keys @keys.drop(current_offset).take(@current_iteration.offset) end
current_offset()
click to toggle source
# File lib/yamlook/handler.rb, line 50 def current_offset @iterations.sum(&:offset) end
end_mapping()
click to toggle source
# File lib/yamlook/handler.rb, line 30 def end_mapping @iterations.pop @current_iteration.reset! end
event_location(start_line, start_column, _end_line, _end_column)
click to toggle source
# File lib/yamlook/handler.rb, line 20 def event_location(start_line, start_column, _end_line, _end_column) @start_line = start_line @start_column = start_column end
keys_out?()
click to toggle source
# File lib/yamlook/handler.rb, line 58 def keys_out? current_offset + @current_iteration.offset == @keys.size end
refresh_current_interation!(value)
click to toggle source
# File lib/yamlook/handler.rb, line 41 def refresh_current_interation!(value) value_keys = value.split(SEPARATOR) value_keys.shift if current_offset.zero? && LOCALES.include?(value_keys.first) @current_iteration.offset = value_keys.count @current_iteration.active = current_keys == value_keys end
scalar(value, _anchor, _tag, _plain, _quoted, _style)
click to toggle source
# File lib/yamlook/handler.rb, line 35 def scalar(value, _anchor, _tag, _plain, _quoted, _style) # rubocop:disable Metrics/ParameterLists @found << [value, @start_line.next, @start_column.next] if keys_out? && all_active? refresh_current_interation!(value) end
start_mapping(_anchor, _tag, _implicit, _style)
click to toggle source
# File lib/yamlook/handler.rb, line 25 def start_mapping(_anchor, _tag, _implicit, _style) @iterations.push(@current_iteration.dup) @current_iteration.reset! end