From 20cf9e3ae8ef05d7fc44e2fda8c5b8233e8eb03e Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Tue, 22 Aug 2023 12:21:35 -0400 Subject: [PATCH] [ruby/yarp] Add a Location#to method for combining them https://github.com/ruby/yarp/commit/1db2de98ac --- lib/yarp.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/yarp.rb b/lib/yarp.rb index f43aaa3d12..4c3cf268ce 100644 --- a/lib/yarp.rb +++ b/lib/yarp.rb @@ -112,6 +112,11 @@ module YARP other.end_offset == end_offset end + # Returns a new location that is the union of this location and the other. + def to(other) + Location.new(source, start_offset, other.end_offset - start_offset) + end + def self.null new(0, 0) end