Class: StructuredReader::JSONReader::Context
- Inherits:
-
Object
- Object
- StructuredReader::JSONReader::Context
- Defined in:
- lib/structured_reader.rb
Instance Method Summary collapse
- #accept(fragment) ⇒ Object
- #flunk(fragment, reason) ⇒ Object
-
#initialize(where = "") ⇒ Context
constructor
A new instance of Context.
- #open(&blk) ⇒ Object
- #push(path) {|self.class.new(@where + path)| ... } ⇒ Object
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
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
340 341 342 |
# File 'lib/structured_reader.rb', line 340 def push(path, &blk) yield self.class.new(@where + path) end |