class Parser::Source::Comment


@api public
@return [Parser::Source::Map]
@!attribute [r] location
@return [String]
@!attribute [r] text
A comment in the source code.
#

def self.associate(ast, comments)

Other tags:
    See: Parser::Source::Comment::Associator -

Returns:
  • (Hash(Parser::AST::Node, Array(Comment))) -

Parameters:
  • comments (Array(Comment)) --
  • ast (Parser::AST::Node) --
def self.associate(ast, comments)
  associator = Associator.new(ast, comments)
  associator.associate
end

def ==(other)

Returns:
  • (Boolean) -

Parameters:
  • other (Object) --
def ==(other)
  other.is_a?(Source::Comment) &&
    @location == other.location
end

def document?

Returns:
  • (Boolean) - true if this is a block comment.

Other tags:
    See: #type -
def document?
  type == :document
end

def initialize(range)

Parameters:
  • range (Parser::Source::Range) --
def initialize(range)
  @location = Parser::Source::Map.new(range)
  @text     = range.source.freeze
  freeze
end

def inline?

Returns:
  • (Boolean) - true if this is an inline comment.

Other tags:
    See: #type -
def inline?
  type == :inline
end

def inspect

Returns:
  • (String) - a human-readable representation of this comment
def inspect
  "#<Parser::Source::Comment #{@location.expression.to_s} #{text.inspect}>"
end

def type

Returns:
  • (Symbol) -
def type
  case text
  when /^#/
    :inline
  when /^=begin/
    :document
  end
end