class RuboCop::AST::NodePattern::Comment

A NodePattern comment, simplified version of ::Parser::Source::Comment

Attributes

loc[R]
location[R]

Public Class Methods

new(range) click to toggle source

@param [Parser::Source::Range] range

# File lib/rubocop/ast/node_pattern/comment.rb, line 14
def initialize(range)
  @location = ::Parser::Source::Map.new(range)
  freeze
end

Public Instance Methods

==(other) click to toggle source

Compares comments. Two comments are equal if they correspond to the same source range.

@param [Object] other @return [Boolean]

# File lib/rubocop/ast/node_pattern/comment.rb, line 31
def ==(other)
  other.is_a?(Comment) &&
    @location == other.location
end
inspect() click to toggle source

@return [String] a human-readable representation of this comment

# File lib/rubocop/ast/node_pattern/comment.rb, line 39
def inspect
  "#<NodePattern::Comment #{@location.expression} #{text.inspect}>"
end
text() click to toggle source

@return [String]

# File lib/rubocop/ast/node_pattern/comment.rb, line 20
def text
  loc.expression.source.freeze
end