struct

Carbon::Version

Inherits Comparable < Struct < Value < Object

Constructors

new(major : Int32, minor : Int32, commit : Int32 = 0, prerelease : String | Nil = nil, build_metadata : String | Nil = nil)
Source
parse(raw : String) : Version

Parse version strings such as: "0.1.42", "v0.1.42", "1.0", "0.0.149-alpha.1", "2.1.5+build.10"

Source

Class methods

parse?(raw : String) : Version | Nil
Source

Instance methods

<=>(other : Version) : Int32

The comparison operator. Returns 0 if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greater than other, or nil if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
Source
build_metadata
Source
build_metadata=(build_metadata : String | Nil)
Source
bump_commit(new_commit_count : Int32 | Nil = nil) : Version

Returns next version bumped for a new commit count

Source
bump_major(reset_commit : Bool = false) : Version

Bumps major version by 1 and resets minor to 0

Source
bump_minor(reset_commit : Bool = false) : Version

Bumps minor version by 1, leaving commit unchanged or optionally resetting to 0

Source
commit
Source
commit=(commit : Int32)
Source
major
Source
major=(major : Int32)
Source
minor
Source
minor=(minor : Int32)
Source
prerelease
Source
prerelease=(prerelease : String | Nil)
Source
to_s(io : IO) : Nil

Same as #inspect(io).

Source
to_tuple
Source
with_major_minor(new_major : Int32, new_minor : Int32) : Version

Sets specific major and minor while keeping commit number synced

Source