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)
- 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)
-
(Boolean)
-
Parameters:
-
other
(Object
) --
def ==(other) other.is_a?(Source::Comment) && @location == other.location end
def document?
-
(Boolean)
- true if this is a block comment.
Other tags:
- See: #type -
def document? type == :document end
def initialize(range)
-
range
(Parser::Source::Range
) --
def initialize(range) @location = Parser::Source::Map.new(range) @text = range.source.freeze freeze end
def inline?
-
(Boolean)
- true if this is an inline comment.
Other tags:
- See: #type -
def inline? type == :inline end
def inspect
-
(String)
- a human-readable representation of this comment
def inspect "#<Parser::Source::Comment #{@location.expression.to_s} #{text.inspect}>" end
def type
-
(Symbol)
-
def type case text when /^#/ :inline when /^=begin/ :document end end