Class: Gem::Version

Class | Gem::Version
In: | lib/rubygems/version.rb
Parent: | Object

The Version class processes string versions into comparable values. A version string should normally be a series of numbers separated by periods. Each part (digits separated by periods) is considered its own number, and these are used for sorting. So for instance, 3.10 sorts higher than 3.2 because ten is greater than two.

If any part contains letters (currently only a-z are supported) then that version is considered prerelease. Versions with a prerelease part in the Nth part sort less than versions with N-1 parts. Prerelease parts are sorted alphabetically using the normal Ruby string sorting rules.

Prereleases sort between real releases (newest to oldest):

1. 1.0
2. 1.0.b
3. 1.0.a
4. 0.9

### Methods

<=> balance bump correct? create eql? marshal_dump marshal_load new normalize parts prerelease? release to_s to_yaml_properties version= yaml_initialize

### Included Modules

Comparable

### Classes and Modules

Class Gem::Version::Part

### Constants

VERSION_PATTERN | = | '[0-9]+(\.[0-9a-z]+)*'

### Attributes

version | [R] |

### Public Class methods

correct?(version)
create(input)

Factory method to create a Version object. Input may be a Version or a String. Intended to simplify client code.

      ver1 = Version.create('1.3.17')   # -> (Version object)
      ver2 = Version.create(ver1)       # -> (ver1)
      ver3 = Version.create(nil)        # -> nil

new(version)

Constructs a Version from the `version` string. A version string is a series of digits or ASCII letters separated by dots.

### Public Instance methods

<=>(other)

Compares this version with `other` returning -1, 0, or 1 if the other version is larger, the same, or smaller than this one.

balance(a, b)
bump()

Return a new version object where the next to the last revision number is one greater. (e.g. 5.3.1 => 5.4)

Pre-release (alpha) parts are ignored. (e.g 5.3.1.b2 => 5.4)

eql?(other)

A Version is only eql? to another version if it has the same version string. "1.0" is not the same version as "1".

marshal_dump()

Dump only the raw version string, not the complete object

marshal_load(array)

Load custom marshal format

normalize()

Strip ignored trailing zeros.

parts()
prerelease?()

A version is considered a prerelease if any part contains a letter.

release()

The release for this version (e.g. 1.2.0.a -> 1.2.0) Non-prerelease versions return themselves

to_s()

Returns the text representation of the version

to_yaml_properties()
version=(version)
yaml_initialize(tag, values)

[Validate]