class Prism::Comment - Documentation for Ruby 4.0
Description: class Prism::Comment: This represents a comment that was encountered during parsing. It is the base class for all comment types.
Keywords: ruby,class,Prism::Comment

🔍

No recent searches

# class Prism::Comment

This represents a comment that was encountered during parsing. It is the base class for all comment types.

### Attributes

location [R]

The location of this comment in the source.

### Public Class Methods

new (location)
Source

    # File lib/prism/parse_result.rb, line 517
    def initialize(location)
      @location = location
    end

Create a new comment object with the given location.

### Public Instance Methods

deconstruct_keys (keys)
Source

    # File lib/prism/parse_result.rb, line 522
    def deconstruct_keys(keys)
      { location: location }
    end

Implement the hash pattern matching interface for `Comment`.

slice ()
Source

    # File lib/prism/parse_result.rb, line 527
    def slice
      location.slice
    end

Returns the content of the comment by slicing it from the source code.