Class: Bundler::VersionRanges::ReqR

Inherits:
Struct
  • Object
show all
Defined in:
lib/bundler/version_ranges.rb,
lib/bundler/version_ranges.rb

Defined Under Namespace

Classes: Endpoint

Constant Summary collapse

INFINITY =
begin
  inf = Object.new
  def inf.to_s
    ""
  end
  def inf.<=>(other)
    return 0 if other.equal?(self)
    1
  end
  inf.freeze
end
ZERO =
Gem::Version.new("0.a")
UNIVERSAL =
ReqR.new(ReqR::Endpoint.new(Gem::Version.new("0.a"), true), ReqR::Endpoint.new(ReqR::INFINITY, false)).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#leftObject

Returns the value of attribute left

Returns:

  • (Object)

    the current value of left



6
7
8
# File 'lib/bundler/version_ranges.rb', line 6

def left
  @left
end

#rightObject

Returns the value of attribute right

Returns:

  • (Object)

    the current value of right



6
7
8
# File 'lib/bundler/version_ranges.rb', line 6

def right
  @right
end

Instance Method Details

#<=>(other) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/bundler/version_ranges.rb', line 66

def <=>(other)
  return -1 if other.equal?(INFINITY)

  comp = left <=> other.left
  return comp unless comp.zero?

  right <=> other.right
end

#cover?(v) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bundler/version_ranges.rb', line 46

def cover?(v)
  return false if left.inclusive && left.version > v
  return false if !left.inclusive && left.version >= v

  if right.version != INFINITY
    return false if right.inclusive && right.version < v
    return false if !right.inclusive && right.version <= v
  end

  true
end

#empty?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/bundler/version_ranges.rb', line 58

def empty?
  left.version == right.version && !(left.inclusive && right.inclusive)
end

#single?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/bundler/version_ranges.rb', line 62

def single?
  left.version == right.version
end

#to_sObject



30
31
32
# File 'lib/bundler/version_ranges.rb', line 30

def to_s
  "#{left.inclusive ? "[" : "("}#{left.version}, #{right.version}#{right.inclusive ? "]" : ")"}"
end