struct SemanticVersion
Overview
Conforms to Semantic Versioning 2.0.0
See https://semver.org/ for more information.
Included Modules
Defined in:
semantic_version.crConstructors
- 
        .new(major : Int, minor : Int, patch : Int, prerelease : String | Prerelease | Nil = nil, build : String? = nil)
        
          Creates a new SemanticVersioninstance with the given major, minor, and patch versions and optionally build and pre-release version
- 
        .parse(str : String) : self
        
          Parses a SemanticVersionfrom the given semantic version string
Instance Method Summary
- 
        #<=>(other : self) : Int32
        
          The comparison operator. 
- 
        #build : String?
        
          The build metadata of this semantic version 
- 
        #major : Int32
        
          The major version of this semantic version 
- 
        #minor : Int32
        
          The minor version of this semantic version 
- 
        #patch : Int32
        
          The patch version of this semantic version 
- 
        #prerelease : Prerelease
        
          The pre-release version of this semantic version 
- 
        #to_s(io : IO) : Nil
        
          Returns the string representation of this semantic version 
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 : IO) : Nil
    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) : Nil
inspect : String 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 : String
to_s(io : IO) : Nil 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) : selffrom_json(string_or_io) : self from_json, from_yaml(string_or_io : String | IO) : self from_yaml
Constructor Detail
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
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.
Instance Method Detail
The comparison operator.
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 "semantic_version"
semver1 = SemanticVersion.new(1, 0, 0)
semver2 = SemanticVersion.new(2, 0, 0)
semver1 <=> semver2 # => -1
semver2 <=> semver2 # => 0
semver2 <=> semver1 # => 1Returns the string representation of this semantic version
require "semantic_version"
semver = SemanticVersion.parse("0.27.1")
semver.to_s # => "0.27.1"