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)
click to toggle source
Create a new magic comment object with the given key and value locations.
# File prism/parse_result.rb, line 433 def initialize(key_loc, value_loc) @key_loc = key_loc @value_loc = value_loc end
Public Instance Methods
deconstruct_keys(keys)
click to toggle source
Implement the hash pattern matching interface for MagicComment
.
# File prism/parse_result.rb, line 449 def deconstruct_keys(keys) { key_loc: key_loc, value_loc: value_loc } end
inspect()
click to toggle source
Returns a string representation of this magic comment.
# File prism/parse_result.rb, line 454 def inspect "#<Prism::MagicComment @key=#{key.inspect} @value=#{value.inspect}>" end
key()
click to toggle source
Returns the key of the magic comment by slicing it from the source code.
# File prism/parse_result.rb, line 439 def key key_loc.slice end
value()
click to toggle source
Returns the value of the magic comment by slicing it from the source code.
# File prism/parse_result.rb, line 444 def value value_loc.slice end