class StructuredReader::JSONReader::SelectionContext

Public Class Methods

new(target, where = "", found = []) click to toggle source
# File lib/structured_reader.rb, line 379
def initialize(target, where = "", found = [])
  @target = target
  @where = where
  @found = found
end

Public Instance Methods

accept(fragment) click to toggle source
# File lib/structured_reader.rb, line 385
def accept(fragment)
  if File.fnmatch(@target, @where)
    @found << fragment
    fragment
  else
    if @found.any?
      @found.first
    else
      unless @where.empty?
        fragment
      end
    end
  end
end
flunk(fragment, reason) click to toggle source
# File lib/structured_reader.rb, line 400
def flunk(fragment, reason)
  nil
end
push(path) { |class.new(target, where + path, found)| ... } click to toggle source
# File lib/structured_reader.rb, line 404
def push(path)
  if @found.empty?
    yield self.class.new(@target, @where + path, @found)
  end
end