Class: Composer::Semver::Comparator

Inherits:
Object
  • Object
show all
Defined in:
lib/composer/semver/comparator.rb

Class Method Summary collapse

Class Method Details

.compare?(version1, operator, version2) ⇒ Boolean

Evaluates the expression: version1 operator version2.

Parameters:

  • version1

    The version 1 string.

  • operator

    The operator to perform the comparison.

  • version2

    The version 2 string.

Returns:

  • (Boolean)

    bool



83
84
85
86
# File 'lib/composer/semver/comparator.rb', line 83

def compare?(version1, operator, version2)
  constraint = ::Composer::Semver::Constraint::Constraint.new(operator, version2)
  constraint.matches?(::Composer::Semver::Constraint::Constraint.new('==', version1))
end

.equal_to?(version1, version2) ⇒ Boolean

Evaluates the expression: version1 == version2.

Parameters:

  • version1

    The version 1 string.

  • version2

    The version 2 string.

Returns:

  • (Boolean)

    bool



62
63
64
# File 'lib/composer/semver/comparator.rb', line 62

def equal_to?(version1, version2)
  self::compare?(version1, '==', version2)
end

.greater_than?(version1, version2) ⇒ Boolean

Evaluates the expression: version1 > version2.

Parameters:

  • version1

    The version 1 string.

  • version2

    The version 2 string.

Returns:

  • (Boolean)

    bool



22
23
24
# File 'lib/composer/semver/comparator.rb', line 22

def greater_than?(version1, version2)
  self::compare?(version1, '>', version2)
end

.greater_than_or_equal_to?(version1, version2) ⇒ Boolean

Evaluates the expression: version1 >= version2.

Parameters:

  • version1

    The version 1 string.

  • version2

    The version 2 string.

Returns:

  • (Boolean)

    bool



32
33
34
# File 'lib/composer/semver/comparator.rb', line 32

def greater_than_or_equal_to?(version1, version2)
  self::compare?(version1, '>=', version2)
end

.less_than?(version1, version2) ⇒ Boolean

Evaluates the expression: version1 < version2.

Parameters:

  • version1

    The version 1 string.

  • version2

    The version 2 string.

Returns:

  • (Boolean)

    bool



42
43
44
# File 'lib/composer/semver/comparator.rb', line 42

def less_than?(version1, version2)
  self::compare?(version1, '<', version2)
end

.less_than_or_equal_to?(version1, version2) ⇒ Boolean

Evaluates the expression: version1 <= version2.

Parameters:

  • version1

    The version 1 string.

  • version2

    The version 2 string.

Returns:

  • (Boolean)

    bool



52
53
54
# File 'lib/composer/semver/comparator.rb', line 52

def less_than_or_equal_to?(version1, version2)
  self::compare?(version1, '<=', version2)
end

.not_equal_to?(version1, version2) ⇒ Boolean

Evaluates the expression: version1 != version2.

Parameters:

  • version1

    The version 1 string.

  • version2

    The version 2 string.

Returns:

  • (Boolean)

    bool



72
73
74
# File 'lib/composer/semver/comparator.rb', line 72

def not_equal_to?(version1, version2)
  self::compare?(version1, '!=', version2)
end