Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Ruby::SourceRange#end_line
source_range.end_line → Integer
proc.c
View on GitHub ↗
static VALUE
source_range_end_line(VALUE self)
{
return INT2NUM(source_range_data_get(self)->end_line);
}
Returns the 1-indexed line number where this source range ends.
Note that this does not include a potential heredoc that spans beyond the callable’s end, for example:
Example
proc { <<~HEREDOC }.source_range.end_line # => 1 heredoc contents HEREDOC
To get the location of the final HEREDOC you can use +Prism.find(Proc|Method|UnboundMethod)+ and then compute the maximum end_line and end_column.