Ruby 4.0 リファレンスマニュアル

instance method RubyVM::AbstractSyntaxTree::Location#first_lineno

first_lineno -> IntegerRuby 3.4 から[permalink][rdoc][edit]
() → Integer

ソースコード中で、この位置情報が指す範囲が始まる行番号を返します。

行番号は1-originです。

loc = RubyVM::AbstractSyntaxTree.parse('1 + 2').locations.first
p loc.first_lineno # => 1