要約
Prism::ParseResult#comments や Prism.#parse_comments で得られる、ソースコード中のコメントを表す抽象基底クラスです。
実際に生成されるのはサブクラスの Prism::InlineComment(# から始まる通常のコメント)または Prism::EmbDocComment(=begin 〜
=end の埋め込みドキュメント)のどちらかで、このクラス自体のインスタンスが返されることはありません。
[SEE_ALSO] Prism::ParseResult#comments, Prism.#parse_comments
目次
- インスタンスメソッド
インスタンスメソッド
location -> Prism::LocationRuby 3.3 から[permalink][rdoc][edit]-
コメントのソースコード上の位置を表す Prism::Location を返します。コメントの文字列そのものは
例location.sliceで取得できます。require "prism" comment = Prism.parse("# hello\n1 + 1").comments.first p comment.location.start_line # => 1 p comment.location.slice # => "# hello"