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.



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

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

Instance Method Details

#accept(fragment) ⇒ Object



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

def accept(fragment)
  fragment
end

#flunk(fragment, reason) ⇒ Object

Raises:



336
337
338
# File 'lib/structured_reader.rb', line 336

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

#open(&blk) ⇒ Object



332
333
334
# File 'lib/structured_reader.rb', line 332

def open(&blk)
  blk.call(self)
end

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

Yields:

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


340
341
342
# File 'lib/structured_reader.rb', line 340

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