class 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
Source
# File lib/prism/parse_result.rb, line 565 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
Source
# File lib/prism/parse_result.rb, line 581 def deconstruct_keys(keys) { key_loc: key_loc, value_loc: value_loc } end
Implement the hash pattern matching interface for MagicComment
.
Source
# File lib/prism/parse_result.rb, line 586 def inspect "#<Prism::MagicComment @key=#{key.inspect} @value=#{value.inspect}>" end
Returns a string representation of this magic comment.
Source
# File lib/prism/parse_result.rb, line 571 def key key_loc.slice end
Returns the key of the magic comment by slicing it from the source code.
Source
# File lib/prism/parse_result.rb, line 576 def value value_loc.slice end
Returns the value of the magic comment by slicing it from the source code.