Class: RubyJsonParser::Result
- Inherits:
- 
      Object
      
        - Object
- RubyJsonParser::Result
 
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_json_parser/result.rb
Overview
The result of parsing a JSON string/file. Combines an AST (Abstract Syntax Tree) and a list of errors.
Instance Attribute Summary collapse
- 
  
    
      #ast  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute ast. 
- 
  
    
      #errors  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute errors. 
Instance Method Summary collapse
- #err? ⇒ Boolean
- 
  
    
      #initialize(ast, errors)  ⇒ Result 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Result. 
- #inspect ⇒ Object
Constructor Details
#initialize(ast, errors) ⇒ Result
Returns a new instance of Result.
| 17 18 19 20 | # File 'lib/ruby_json_parser/result.rb', line 17 def initialize(ast, errors) @ast = ast @errors = errors end | 
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
| 11 12 13 | # File 'lib/ruby_json_parser/result.rb', line 11 def ast @ast end | 
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
| 14 15 16 | # File 'lib/ruby_json_parser/result.rb', line 14 def errors @errors end | 
Instance Method Details
#err? ⇒ Boolean
| 23 24 25 | # File 'lib/ruby_json_parser/result.rb', line 23 def err? @errors.any? end | 
#inspect ⇒ Object
| 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # File 'lib/ruby_json_parser/result.rb', line 28 def inspect buff = String.new buff << "<RubyJsonParser::Result>\n" if @errors.any? buff << " !Errors!\n" @errors.each do |err| buff << " - #{err}\n" end buff << "\n" end buff << " AST:\n" buff << @ast.inspect(2) end |