Skip to content

struct SemanticVersion::Prerelease
inherits Struct

Contains the pre-release version related to this semantic version

Included modules

Comparable

Class methods

.new(identifiers : Array(String | Int32) = [] of String | Int32)

Creates a new Prerelease instance with supplied array of identifiers

View source

.parse(str : String) : self

Parses a Prerelease from the given pre-release version string

require "semantic_version"

prerelease = SemanticVersion::Prerelease.parse("rc.1.3")
prerelease # => SemanticVersion::Prerelease(@identifiers=["rc", 1, 3])
View source

Methods

#<=>(other : self) : Int32

The comparison operator.

Returns -1, 0 or 1 depending on whether self's pre-release is lower than other's, equal to other's pre-release or greater than other's pre-release.

require "semantic_version"

prerelease1 = SemanticVersion::Prerelease.new(["rc", 1])
prerelease2 = SemanticVersion::Prerelease.new(["rc", 1, 2])

prerelease1 <=> prerelease2 # => -1
prerelease1 <=> prerelease1 # => 0
prerelease2 <=> prerelease1 # => 1
View source

#identifiers : Array(String | Int32)

Array of identifiers that make up the pre-release metadata

View source

#to_s(io : IO) : Nil

Returns the string representation of this semantic version's pre-release metadata

require "semantic_version"

semver = SemanticVersion.parse("0.27.1-rc.1")
semver.prerelease.to_s # => "rc.1"
View source