struct SemanticVersion

Overview

Conforms to Semantic Versioning 2.0.0

See https://semver.org/ for more information.

Included Modules

Defined in:

short_version/extensions/semantic_version.cr

Constructors

Instance Method Summary

Constructor Detail

def self.parse(str : ShortVersion) : self #

Parses a SemanticVersion from the given ShortVersion

require "short_version/ext/semantic_version"

shortver = ShortVersion.parse("1.23")
semver = SemanticVersion.parse(shortver)
semver # => SemanticVersion(@major=1, @minor=23, @patch=0, ... )

[View source]

Instance Method Detail

def <=>(other : ShortVersion) : Int32 #

The comparison operator with ShortVersion.

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

require "short_version/ext/semantic_version"

SemanticVersion.parse("1.2.3") <=> ShortVersion.parse("1.3") # => -1
SemanticVersion.parse("1.2.3") <=> ShortVersion.parse("1.2") # => 0
SemanticVersion.parse("1.2.3") <=> ShortVersion.parse("1.1") # => 1

[View source]
def to_shortver #

Returns the ShortVersion representation of this semantic version

require "short_version/ext/semantic_version"

semver = SemanticVersion.parse("0.39.3")
semver.to_shortver # => ShortVersion(@major=0, @minor=39)

[View source]