Class: Ruby2D::JsonParser::Parser
- Inherits:
-
Object
- Object
- Ruby2D::JsonParser::Parser
- Defined in:
- lib/ruby2d/json_parser.rb
Constant Summary collapse
- MAX_DEPTH =
Cap nesting depth so pathological input fails with a ParseError rather than overflowing the Ruby stack with a SystemStackError. Real texture atlases nest only a handful of levels deep.
500
Instance Method Summary collapse
-
#initialize(str) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(str) ⇒ Parser
Returns a new instance of Parser.
20 21 22 23 24 |
# File 'lib/ruby2d/json_parser.rb', line 20 def initialize(str) @s = str @i = 0 @depth = 0 end |
Instance Method Details
#parse ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/ruby2d/json_parser.rb', line 26 def parse skip_ws value = parse_value skip_ws raise ParseError, "unexpected trailing data at offset #{@i}" if @i < @s.length value end |