Object
A comment in the source code.
@!attribute [r] text
@return [String]
@!attribute [r] location
@return [Parser::Source::Map]
@api public
Associate `comments` with `ast` nodes by their location in the source.
@param [Parser::AST::Node] ast @param [Array(Comment)] comments @return [Hash(Parser::AST::Node, Array(Comment))] @see Parser::Source::Comment::Associator
# File lib/parser/source/comment.rb, line 30 def self.associate(ast, comments) associator = Associator.new(ast, comments) associator.associate end
Compares comments. Two comments are equal if they correspond to the same source range.
@param [Object] other @return [Boolean]
# File lib/parser/source/comment.rb, line 92 def ==(other) other.is_a?(Source::Comment) && @location == other.location end
@see type @return [Boolean] true if this is a block comment.
# File lib/parser/source/comment.rb, line 81 def document? type == :document end
@see type @return [Boolean] true if this is an inline comment.
# File lib/parser/source/comment.rb, line 73 def inline? type == :inline end
@return [String] a human-readable representation of this comment
# File lib/parser/source/comment.rb, line 100 def inspect "#<Parser::Source::Comment #{@location.expression.to_s} #{text.inspect}>" end
Type of this comment.
* Inline comments correspond to `:inline`: # whatever * Block comments correspond to `:document`: =begin hi i am a document =end
@return [Symbol]
# File lib/parser/source/comment.rb, line 60 def type case text when /^#/ :inline when /^=begin/ :document end end
Generated with the Darkfish Rdoc Generator 2.