struct

Outdated::Version

Inherits Comparable < Struct < Value < Object

A Outdated::Version describes a version number with #major, #minor, #micro, and #nano components. Components beyond the #major number may be nil. Note that the largest value for any component is 2^16 - 1 (65535).

Constructors

new(major : UInt16, minor : UInt16 | Nil = nil, micro : UInt16 | Nil = nil, nano : UInt16 | Nil = nil)

Create a new Outdated::Version struct. The major number must not be nil, but the other components may be.

Source

Class methods

parse?(version) : Version | Nil

Parse a string into a Outdated::Version structure. If the version string is not a valid version string, then nil is returned.

version = Outdated::Version.parse?("1.2.3")
version.major # => 1
version.minor # => 2
version.micro # => 3
version.nano # => nil

Outdated::Version.parse?("1.2-beta") => nil
Source

Instance methods

<=>(other)

Compare two Outdated::Version values to each other. Conventional version ordering is used.

v_1_2 = Outdated::Version.parse?("1.2")
v_1_2_0 = Outdated::Version.parse?("1.2.0")
v_1_2_1 = Outdated::Version.parse?("1.2.1")
v_1_10 = Outdated::Version.parse?("1.10")

v_1_2_1 < v_10    # => true
v_1_2_0 < v_1_2_1 # => true
v_1_2 < v_1_2_1   # => true
v_1_2 < v_1_2_0   # => true
Source
distance(other : Version) : UInt64

Determine the distance to anotherOutdated::Version value. The distance is defined as the the absolute difference between the #to_u64 values of the versions.

Source
major
Source
micro
Source
minor
Source
nano
Source
to_a

Convert an Outdated::Version to a four element Array(UInt16?).

Source
to_s(io)

Convert an Outdated::Version to a string. Normal version dot-notation is used for the version number.

Outdated::Version.new(1, 2, 3).to_s # => "1.2.3"
Source
to_u64

Convert an Outdated::Version to a UInt64. This is done by concatenating each component (#major, #minor, #micro, #nano) into a UInt64. nil values are treated as zeros.

Source