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

instance method Prism::Location#join

join(other) -> Prism::LocationRuby 3.3 から[permalink][rdoc][edit]

自身の開始位置から other の終端位置までを表す新しい Prism::Location を返します。間にある文字列も範囲に含まれます。

[PARAM] other:
結合する Prism::Location。自身より後ろにある必要があります。
require "prism"

body = Prism.parse("foo = 1\nbar = 2\n").value.statements.body
p body[0].location.join(body[1].location).slice
# => "foo = 1\nbar = 2"