class Ruby::Prism::MagicComment

This represents a magic comment that was encountered during parsing.

Attributes

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

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

Public Class Methods

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

: (Location key_loc, Location value_loc) -> void

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

Public Instance Methods

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

: () -> String

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

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

: () -> String

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