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-master/lib/prism/parse_result.rb, line 433
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-master/lib/prism/parse_result.rb, line 449
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-master/lib/prism/parse_result.rb, line 454
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-master/lib/prism/parse_result.rb, line 439
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-master/lib/prism/parse_result.rb, line 444
def value
value_loc.slice
end
Returns the value of the magic comment by slicing it from the source code.