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.
512 513 514 |
# File 'lib/prism/parse_result.rb', line 512 def initialize(location) @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
The location of this comment in the source.
509 510 511 |
# File 'lib/prism/parse_result.rb', line 509 def location @location end |
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
Implement the hash pattern matching interface for Comment.
517 518 519 |
# File 'lib/prism/parse_result.rb', line 517 def deconstruct_keys(keys) { location: location } end |
#slice ⇒ Object
Returns the content of the comment by slicing it from the source code.
522 523 524 |
# File 'lib/prism/parse_result.rb', line 522 def slice location.slice end |