Class: YARP::ParseResult
- Inherits:
-
Object
- Object
- YARP::ParseResult
- Defined in:
- lib/yarp.rb,
ext/yarp/extension.c
Overview
This represents the result of a call to ::parse or ::parse_file. It contains the AST, any comments that were encounters, and any errors that were encountered.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
- #deconstruct_keys(keys) ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(value, comments, errors, warnings, source) ⇒ ParseResult
constructor
A new instance of ParseResult.
- #mark_newlines ⇒ Object
- #success? ⇒ Boolean
-
#with_source(source) ⇒ Object
Construct a new ParseResult with the same internal values, but with the given source.
Constructor Details
#initialize(value, comments, errors, warnings, source) ⇒ ParseResult
Returns a new instance of ParseResult.
181 182 183 184 185 186 187 |
# File 'lib/yarp.rb', line 181 def initialize(value, comments, errors, warnings, source) @value = value @comments = comments @errors = errors @warnings = warnings @source = source end |
Instance Attribute Details
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
179 180 181 |
# File 'lib/yarp.rb', line 179 def comments @comments end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
179 180 181 |
# File 'lib/yarp.rb', line 179 def errors @errors end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
179 180 181 |
# File 'lib/yarp.rb', line 179 def source @source end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
179 180 181 |
# File 'lib/yarp.rb', line 179 def value @value end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
179 180 181 |
# File 'lib/yarp.rb', line 179 def warnings @warnings end |
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
189 190 191 |
# File 'lib/yarp.rb', line 189 def deconstruct_keys(keys) { value: value, comments: comments, errors: errors, warnings: warnings } end |
#failure? ⇒ Boolean
197 198 199 |
# File 'lib/yarp.rb', line 197 def failure? !success? end |
#mark_newlines ⇒ Object
233 234 235 236 237 238 |
# File 'lib/yarp.rb', line 233 def mark_newlines newline_marked = Array.new(1 + @source.offsets.size, false) visitor = MarkNewlinesVisitor.new(newline_marked) value.accept(visitor) value end |
#success? ⇒ Boolean
193 194 195 |
# File 'lib/yarp.rb', line 193 def success? errors.empty? end |
#with_source(source) ⇒ Object
Construct a new ParseResult with the same internal values, but with the given source.
242 243 244 |
# File 'lib/yarp.rb', line 242 def with_source(source) ParseResult.new(value, comments, errors, warnings, source) end |