class Net::SCP::Version
A class for describing the current version of a library. The version consists of three parts: the major
number, the minor
number, and the tiny
(or patch
) number.
Two Version
instances may be compared, so that you can test that a version of a library is what you require:
require 'net/scp/version' if Net::SCP::Version::CURRENT < Net::SCP::Version[2,1,0] abort "your software is too old!" end
Constants
- CURRENT
-
The current version of the
Net::SSH
library as aVersion
instance - MAJOR
-
The major component of this version of the
Net::SSH
library - MINOR
-
The minor component of this version of the
Net::SSH
library - PRE
-
The prerelease component of this version of the
Net::SSH
library nil allowed - STRING
-
The current version of the
Net::SSH
library as a String - TINY
-
The tiny component of this version of the
Net::SSH
library
Attributes
Public Class Methods
Source
# File lib/net/scp/version.rb, line 20 def self.[](major, minor, tiny, pre = nil) new(major, minor, tiny, pre) end
A convenience method for instantiating a new Version
instance with the given major
, minor
, and tiny
components.
Source
# File lib/net/scp/version.rb, line 27 def initialize(major, minor, tiny, pre = nil) @major, @minor, @tiny, @pre = major, minor, tiny, pre end
Create a new Version
object with the given components.
Public Instance Methods
Source
# File lib/net/scp/version.rb, line 32 def <=>(version) to_i <=> version.to_i end
Compare this version to the given version
object.
Source
# File lib/net/scp/version.rb, line 44 def to_i @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny end
Converts this version to a canonical integer that may be compared against other version objects.
Source
# File lib/net/scp/version.rb, line 38 def to_s @to_s ||= [@major, @minor, @tiny, @pre].compact.join(".") end
Converts this version object to a string, where each of the three version components are joined by the ‘.’ character. E.g., 2.0.0.