W3cubDocs

/Crystal 0.31

struct SemanticVersion::Prerelease

Overview

Contains the pre-release version related to this semantic version

Defined in:

semantic_version.cr

Constructors

Instance Method Summary

Constructor Detail

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

Creates a new Prerelease instance with supplied array of identifiers

def self.parse(str : String) : selfSource

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])

Instance Method Detail

def <=>(other : self) : Int32Source

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

def identifiers : Array(String | Int32)Source

Array of identifiers that make up the pre-release metadata

def to_s(io : IO) : NilSource

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"

© 2012–2019 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.31.1/SemanticVersion/Prerelease.html