class Prism::MagicComment - Documentation for Ruby 4.1
Description: class Prism::MagicComment: This represents a magic comment that was encountered during parsing.
Keywords: ruby,class,Prism::MagicComment

🔍

No recent searches

# class Prism::MagicComment

This represents a magic comment that was encountered during parsing.

### Attributes

key_loc [R]

A `Location` object representing the location of the key in the source.

value_loc [R]

A `Location` object representing the location of the value in the source.

### Public Class Methods

new (key_loc, value_loc)
Source

    # File lib/prism/parse_result.rb, line 786
    def initialize(key_loc, value_loc)
      @key_loc = key_loc
      @value_loc = value_loc
    end

Create a new magic comment object with the given key and value locations.

### Public Instance Methods

key ()
Source

    # File lib/prism/parse_result.rb, line 794
    def key
      key_loc.slice
    end

Returns the key of the magic comment by slicing it from the source code.

value ()
Source

    # File lib/prism/parse_result.rb, line 801
    def value
      value_loc.slice
    end

Returns the value of the magic comment by slicing it from the source code.