Class: StructuredReader::JSONReader::Context

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

Instance Method Summary collapse

Constructor Details

#initialize(where = "") ⇒ Context

Returns a new instance of Context.



315
316
317
# File 'lib/structured_reader.rb', line 315

def initialize(where = "")
  @where = where.dup.freeze
end

Instance Method Details

#accept(fragment) ⇒ Object



319
320
321
# File 'lib/structured_reader.rb', line 319

def accept(fragment)
  fragment
end

#flunk(fragment, reason) ⇒ Object

Raises:



323
324
325
# File 'lib/structured_reader.rb', line 323

def flunk(fragment, reason)
  raise WrongTypeError, "#{reason}, got a #{fragment.class} (at #{@where})"
end

#push(path) {|self.class.new(@where + path)| ... } ⇒ Object

Yields:

  • (self.class.new(@where + path))


327
328
329
# File 'lib/structured_reader.rb', line 327

def push(path, &blk)
  yield self.class.new(@where + path)
end