Class: Semver::Identifier Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Identifier

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Identifier.

Parameters:



8
9
10
# File 'lib/semver/identifier.rb', line 8

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueString, Integer (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



13
14
15
# File 'lib/semver/identifier.rb', line 13

def value
  @value
end

Class Method Details

.new(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:



27
28
29
30
31
# File 'lib/semver/identifier.rb', line 27

def self.new(value)
  identifier = allocate
  identifier.send(:initialize, value =~ /^\d+$/ ? value.to_i : value)
  identifier
end

Instance Method Details

#<=>(other) ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns -1, 0, or 1.

Returns:

  • (Integer)

    Returns -1, 0, or 1.



16
17
18
19
20
21
22
23
24
# File 'lib/semver/identifier.rb', line 16

def <=>(other)
  if other.value.is_a?(value.class)
    value <=> other.value
  elsif value.is_a?(Integer)
    -1
  else
    1
  end
end