Class: VersionBoss::Gem::Version::PreReleaseIdentifier Private

Inherits:
Object
  • Object
show all
Defined in:
lib/version_boss/gem/version.rb

Overview

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.

A pre-release part of a version which consists of an optional prefix and an identifier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pre_release_part_str) ⇒ String

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.

Create a new PreReleaseIdentifier keeping track of the optional prefix

Examples:

PreReleaseIdentifier.new('.pre') #=> #<PreReleaseIdentifier @identifier="pre", @prefix=".">
PreReleaseIdentifier.new('pre') #=> #<PreReleaseIdentifier @identifier="pre", @prefix="">
PreReleaseIdentifier.new('.1') #=> #<PreReleaseIdentifier @identifier=1, @prefix=".">
PreReleaseIdentifier.new('1') #=> #<PreReleaseIdentifier @identifier=1, @prefix="">

Parameters:

  • pre_release_part_str (String)

    the pre-release part string to parse



404
405
406
407
# File 'lib/version_boss/gem/version.rb', line 404

def initialize(pre_release_part_str)
  @prefix = pre_release_part_str.start_with?('.') ? '.' : ''
  @identifier = determine_part(pre_release_part_str)
end

Instance Attribute Details

#identifierString, 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.

The pre-release identifier

The identifier is converted to an integer if it consists only of digits. Otherwise, it is left as a string.

Returns:

  • (String, Integer)


388
389
390
# File 'lib/version_boss/gem/version.rb', line 388

def identifier
  @identifier
end

#prefixString (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.

Gem versions can optionally prefix pre-release identifiers with a period

The prefix is not significant when sorting.

The prefix is saved so that the pre-release part can be reconstructed exactly as it was given.

Returns:

  • (String)

    '.' if the pre-release type is prefixed with a period, otherwise ''



375
376
377
# File 'lib/version_boss/gem/version.rb', line 375

def prefix
  @prefix
end