Class
This represents a magic comment that was encountered during parsing.
Attributes
Class Methods
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 424
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.
Instance Methods
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 440
def deconstruct_keys(keys)
{ key_loc: key_loc, value_loc: value_loc }
end
Implement the hash pattern matching interface for MagicComment
.
#
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 445
def inspect
"#<Prism::MagicComment @key=#{key.inspect} @value=#{value.inspect}>"
end
Returns a string representation of this magic comment.
#
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 430
def key
key_loc.slice
end
Returns the key of the magic comment by slicing it from the source code.
#
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 435
def value
value_loc.slice
end
Returns the value of the magic comment by slicing it from the source code.