struct SemanticVersion

Overview

Conforms to Semantic Versioning 2.0.0

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

Included Modules

Defined in:

semantic_version.cr

Constructors

Instance Method Summary

Instance methods inherited from module Comparable(SemanticVersion)

<(other : T) <, <=(other : T) <=, <=>(other : T) <=>, ==(other : T) ==, >(other : T) >, >=(other : T) >=

Instance methods inherited from struct Struct

==(other) : Bool ==, hash(hasher) hash, inspect(io : IO) : Nil inspect, pretty_print(pp) : Nil pretty_print, to_s(io) to_s

Instance methods inherited from struct Value

==(other : JSON::Any)
==(other : YAML::Any)
==(other)
==
, dup dup

Instance methods inherited from class Object

!=(other) !=, !~(other) !~, ==(other) ==, ===(other : JSON::Any)
===(other : YAML::Any)
===(other)
===
, =~(other) =~, class class, dup dup, hash(hasher)
hash
hash
, inspect(io : IO)
inspect
inspect
, itself itself, not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, tap(&block) tap, to_json(io : IO)
to_json
to_json
, to_pretty_json(indent : String = " ")
to_pretty_json(io : IO, indent : String = " ")
to_pretty_json
, to_s
to_s(io : IO)
to_s
, to_yaml(io : IO)
to_yaml
to_yaml
, try(&block) try, unsafe_as(type : T.class) forall T unsafe_as

Constructor methods inherited from class Object

from_json(string_or_io, root : String) : self
from_json(string_or_io) : self
from_json
, from_yaml(string_or_io : String | IO) : self from_yaml

Constructor Detail

def self.new(major : Int, minor : Int, patch : Int, prerelease : String | Prerelease | Nil = nil, build : String? = nil) #

Creates a new SemanticVersion instance with the given major, minor, and patch versions and optionally build and pre-release version

Raises ArgumentError if prerelease is invalid pre-release version


[View source]
def self.parse(str : String) : self #

Parses a SemanticVersion from the given semantic version string

require "semantic_version"

semver = SemanticVersion.parse("2.61.4")
semver # => #<SemanticVersion:0x55b3667c9e70 @major=2, @minor=61, @patch=4, ... >

Raises ArgumentError if str is not a semantic version.


[View source]

Instance Method Detail

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

The comparison operator

require "semantic_version"

semver1 = SemanticVersion.new(1, 0, 0)
semver2 = SemanticVersion.new(2, 0, 0)

semver1 <=> semver2 # => -1
semver2 <=> semver2 # => 0
semver2 <=> semver1 # => 1

[View source]
def build : String? #

The build metadata of this semantic version


[View source]
def major : Int32 #

The major version of this semantic version


[View source]
def minor : Int32 #

The minor version of this semantic version


[View source]
def patch : Int32 #

The patch version of this semantic version


[View source]
def prerelease : Prerelease #

The pre-release version of this semantic version


[View source]
def to_s(io : IO) #

Returns the string representation of this semantic version

require "semantic_version"

semver = SemanticVersion.parse("0.27.1")
semver.to_s # => "0.27.1"

[View source]