Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Ruby::SourceRange#end_column

source_range.end_column → Integer

Returns the 0-indexed byte column 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_column # => 19
  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.