Class: Prism::Result
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
|
|
| Inherits: | Object |
| Defined in: | lib/prism/parse_result.rb, prism/extension.c |
Overview
This represents the result of a call to parse or parse_file. It contains the requested structure, any comments that were encounters, and any errors that were encountered.
Class Method Summary
-
.new(comments, magic_comments, data_loc, errors, warnings, source) ⇒ Result
constructor
Create a new result object with the given values.
Instance Attribute Summary
-
#comments
readonly
The list of comments that were encountered during parsing.
-
#data_loc
readonly
An optional location that represents the location of the END marker and the rest of the content of the file.
-
#errors
readonly
The list of errors that were generated during parsing.
-
#failure? ⇒ Boolean
readonly
Returns true if there were errors during parsing and false if there were not.
-
#magic_comments
readonly
The list of magic comments that were encountered during parsing.
-
#source
readonly
A Source instance that represents the source code that was parsed.
-
#success? ⇒ Boolean
readonly
Returns true if there were no errors during parsing and false if there were.
-
#warnings
readonly
The list of warnings that were generated during parsing.
Instance Method Summary
-
#code_units_cache(encoding)
Create a code units cache for the given encoding.
-
#deconstruct_keys(keys)
Implement the hash pattern matching interface for
Result. -
#encoding
Returns the encoding of the source code that was parsed.
Constructor Details
.new(comments, magic_comments, data_loc, errors, warnings, source) ⇒ Result
Create a new result object with the given values.
Instance Attribute Details
#comments (readonly)
The list of comments that were encountered during parsing.
# File 'lib/prism/parse_result.rb', line 669
attr_reader :comments
#data_loc (readonly)
An optional location that represents the location of the END marker and the rest of the content of the file. This content is loaded into the DATA constant when the file being parsed is the main file being executed.
# File 'lib/prism/parse_result.rb', line 677
attr_reader :data_loc
#errors (readonly)
The list of errors that were generated during parsing.
# File 'lib/prism/parse_result.rb', line 680
attr_reader :errors
#failure? ⇒ Boolean (readonly)
Returns true if there were errors during parsing and false if there were not.
# File 'lib/prism/parse_result.rb', line 716
def failure? !success? end
#magic_comments (readonly)
The list of magic comments that were encountered during parsing.
# File 'lib/prism/parse_result.rb', line 672
attr_reader :magic_comments
#source (readonly)
A Source instance that represents the source code that was parsed.
# File 'lib/prism/parse_result.rb', line 686
attr_reader :source
#success? ⇒ Boolean (readonly)
Returns true if there were no errors during parsing and false if there were.
# File 'lib/prism/parse_result.rb', line 710
def success? errors.empty? end
#warnings (readonly)
The list of warnings that were generated during parsing.
# File 'lib/prism/parse_result.rb', line 683
attr_reader :warnings
Instance Method Details
#code_units_cache(encoding)
Create a code units cache for the given encoding.
#deconstruct_keys(keys)
Implement the hash pattern matching interface for Result.
# File 'lib/prism/parse_result.rb', line 699
def deconstruct_keys(keys) { comments: comments, magic_comments: magic_comments, data_loc: data_loc, errors: errors, warnings: warnings } end
#encoding
Returns the encoding of the source code that was parsed.
# File 'lib/prism/parse_result.rb', line 704
def encoding source.encoding end