Skip to content

Commit 1db2de9

Browse files
committed
Add a Location#to method for combining them
1 parent c8f31eb commit 1db2de9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/yarp.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ def ==(other)
112112
other.end_offset == end_offset
113113
end
114114

115+
# Returns a new location that is the union of this location and the other.
116+
def to(other)
117+
Location.new(source, start_offset, other.end_offset - start_offset)
118+
end
119+
115120
def self.null
116121
new(0, 0)
117122
end

0 commit comments

Comments
 (0)