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
Constructor Details
#initialize(value, comments, errors, warnings, source) ⇒ ParseResult
Returns a new instance of ParseResult.
171 172 173 174 175 176 177 |
# File 'lib/yarp.rb', line 171 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.
169 170 171 |
# File 'lib/yarp.rb', line 169 def comments @comments end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
169 170 171 |
# File 'lib/yarp.rb', line 169 def errors @errors end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
169 170 171 |
# File 'lib/yarp.rb', line 169 def source @source end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
169 170 171 |
# File 'lib/yarp.rb', line 169 def value @value end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
169 170 171 |
# File 'lib/yarp.rb', line 169 def warnings @warnings end |
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
179 180 181 |
# File 'lib/yarp.rb', line 179 def deconstruct_keys(keys) { value: value, comments: comments, errors: errors, warnings: warnings } end |
#failure? ⇒ Boolean
187 188 189 |
# File 'lib/yarp.rb', line 187 def failure? !success? end |
#mark_newlines ⇒ Object
223 224 225 226 227 228 |
# File 'lib/yarp.rb', line 223 def mark_newlines newline_marked = Array.new(1 + @source.offsets.size, false) visitor = MarkNewlinesVisitor.new(newline_marked) value.accept(visitor) value end |
#success? ⇒ Boolean
183 184 185 |
# File 'lib/yarp.rb', line 183 def success? errors.empty? end |