Class: Prism::Comment
- Inherits:
-
Object
- Object
- Prism::Comment
- Defined in:
- lib/prism/parse_result.rb,
ext/prism/extension.c
Overview
This represents a comment that was encountered during parsing. It is the base class for all comment types.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
The location of this comment in the source.
Instance Method Summary collapse
-
#deconstruct_keys(keys) ⇒ Object
Implement the hash pattern matching interface for Comment.
-
#initialize(location) ⇒ Comment
constructor
Create a new comment object with the given location.
-
#slice ⇒ Object
Returns the content of the comment by slicing it from the source code.
Constructor Details
#initialize(location) ⇒ Comment
Create a new comment object with the given location.
530 531 532 |
# File 'lib/prism/parse_result.rb', line 530 def initialize(location) @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
The location of this comment in the source.
527 528 529 |
# File 'lib/prism/parse_result.rb', line 527 def location @location end |
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
Implement the hash pattern matching interface for Comment.
535 536 537 |
# File 'lib/prism/parse_result.rb', line 535 def deconstruct_keys(keys) { location: location } end |
#slice ⇒ Object
Returns the content of the comment by slicing it from the source code.
540 541 542 |
# File 'lib/prism/parse_result.rb', line 540 def slice location.slice end |