Short answer: no, not in the way you want, not with Ruby's standard runtime APIs.
Why
The call stack (caller, caller_locations, and friends) is designed to tell you where the currently executing frame was called, not the full source range of the call expression. That’s why you only see "file:line:in …" (and optionally the method name).
Ruby does not retain, at runtime, the parsed AST or column ranges of method call sites. That information is only available during parsing (via Ripper, Prism, etc.) or via external tooling (e.g. debuggers, profilers).
What you can get
With caller_locations, you can access:
• path (filename)
• lineno (line number where the call originated)
• label (method / block / eval context)
• base_label (similar, less decorated)
• absolute_path
…but no column offsets or end positions.
Workarounds
If you truly need start/end column info:
1. Parse the source file yourself
Use Ripper.lex (standard lib) or Prism (newer parser) to extract the location ranges for method calls. You can then correlate caller_locations.first.lineno with a call expression in the source and find its columns.
Example:
require 'ripper'
require 'pp'
code = File.read("sample.rb")
pp Ripper.lex(code).select { |(_, line, col), type, str|
line == 8
}
That gives you tokens at line 8 with exact columns.
2. Use TracePoint
You can attach to :call / :c_call / :line events and inspect locations, but you still won’t get column ranges directly. You’d have to combine with source parsing.
3. External tools
Debuggers (e.g. byebug, debug gem) and coverage tools use parsing + runtime hooks together. They don’t magically get ranges from the VM either.
Conclusion
The Ruby VM at runtime only knows file and line. If you want columns and end positions, you need to reparse the source (via Ripper or Prism). There is no built-in way to ask Ruby for "sample.rb:8:0-12:1" during execution.
Would you like me to sketch a helper that wraps caller_locations + Ripper so you can pretty-print call sites with start/end columns automatically?