Method: Bundler::PubGrub::VersionRange#span

Defined in:
lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb

#span(other) ⇒ Object

The span covered by two ranges

If self and other are contiguous, this builds a union of the two ranges. (if they aren’t you are probably calling the wrong method)

[View source]

259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb', line 259

def span(other)
  return self if other.empty?

  min_range =
    if !min
      self
    elsif !other.min
      other
    else
      case min <=> other.min
      when 0
        include_min ? self : other
      when -1
        self
      when 1
        other
      end
    end

  max_range =
    if !max
      self
    elsif !other.max
      other
    else
      case max <=> other.max
      when 0
        include_max ? self : other
      when -1
        other
      when 1
        self
      end
    end

  VersionRange.new(
    min: min_range.min,
    include_min: min_range.include_min,
    max: max_range.max,
    include_max: max_range.include_max
  )
end