Class Net::SSH::Version

  1. lib/net/ssh/version.rb
Parent: Object

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/ssh/version'

if Net::SSH::Version::CURRENT < Net::SSH::Version[2,1,0]
  abort "your software is too old!"
end

Methods

public class

  1. []
  2. new

public instance

  1. <=>
  2. to_i
  3. to_s

Included modules

  1. Comparable

Constants

MAJOR = 2   The major component of this version of the Net::SSH library
MINOR = 1   The minor component of this version of the Net::SSH library
TINY = 0   The tiny component of this version of the Net::SSH library
CURRENT = new(MAJOR, MINOR, TINY)   The current version of the Net::SSH library as a Version instance
STRING = CURRENT.to_s   The current version of the Net::SSH library as a String

Attributes

major [R]
minor [R]
tiny [R]

Public class methods

[] (major, minor, tiny)

A convenience method for instantiating a new Version instance with the given major, minor, and tiny components.

[show source]
    # File lib/net/ssh/version.rb, line 19
19:     def self.[](major, minor, tiny)
20:       new(major, minor, tiny)
21:     end
new (major, minor, tiny)

Create a new Version object with the given components.

[show source]
    # File lib/net/ssh/version.rb, line 26
26:     def initialize(major, minor, tiny)
27:       @major, @minor, @tiny = major, minor, tiny
28:     end

Public instance methods

<=> (version)

Compare this version to the given version object.

[show source]
    # File lib/net/ssh/version.rb, line 31
31:     def <=>(version)
32:       to_i <=> version.to_i
33:     end
to_i ()

Converts this version to a canonical integer that may be compared against other version objects.

[show source]
    # File lib/net/ssh/version.rb, line 43
43:     def to_i
44:       @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny
45:     end
to_s ()

Converts this version object to a string, where each of the three version components are joined by the ’.’ character. E.g., 2.0.0.

[show source]
    # File lib/net/ssh/version.rb, line 37
37:     def to_s
38:       @to_s ||= [@major, @minor, @tiny].join(".")
39:     end