Class: AuthlogicLdap::Version
- Inherits:
-
Object
- Object
- AuthlogicLdap::Version
- Includes:
- Comparable
- Defined in:
- lib/authlogic_ldap/version.rb
Overview
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.
Constant Summary
- MAJOR =
0- MINOR =
0- TINY =
9- CURRENT =
The current version as a Version instance
new(MAJOR, MINOR, TINY)
- STRING =
The current version as a String
CURRENT.to_s
Instance Attribute Summary (collapse)
-
- (Object) major
readonly
Returns the value of attribute major.
-
- (Object) minor
readonly
Returns the value of attribute minor.
-
- (Object) tiny
readonly
Returns the value of attribute tiny.
Class Method Summary (collapse)
-
+ (Object) [](major, minor, tiny)
A convenience method for instantiating a new Version instance with the given major, minor, and tiny components.
Instance Method Summary (collapse)
-
- (Object) <=>(version)
Compare this version to the given version object.
-
- (Version) initialize(major, minor, tiny)
constructor
Create a new Version object with the given components.
- - (Object) to_a
-
- (Object) to_i
Converts this version to a canonical integer that may be compared against other version objects.
-
- (Object) to_s
Converts this version object to a string, where each of the three version components are joined by the '.' character.
Constructor Details
- (Version) initialize(major, minor, tiny)
Create a new Version object with the given components.
17 18 19 |
# File 'lib/authlogic_ldap/version.rb', line 17 def initialize(major, minor, tiny) @major, @minor, @tiny = major, minor, tiny end |
Instance Attribute Details
- (Object) major (readonly)
Returns the value of attribute major
14 15 16 |
# File 'lib/authlogic_ldap/version.rb', line 14 def major @major end |
- (Object) minor (readonly)
Returns the value of attribute minor
14 15 16 |
# File 'lib/authlogic_ldap/version.rb', line 14 def minor @minor end |
- (Object) tiny (readonly)
Returns the value of attribute tiny
14 15 16 |
# File 'lib/authlogic_ldap/version.rb', line 14 def tiny @tiny end |
Class Method Details
+ (Object) [](major, minor, tiny)
A convenience method for instantiating a new Version instance with the given major, minor, and tiny components.
10 11 12 |
# File 'lib/authlogic_ldap/version.rb', line 10 def self.[](major, minor, tiny) new(major, minor, tiny) end |
Instance Method Details
- (Object) <=>(version)
Compare this version to the given version object.
22 23 24 |
# File 'lib/authlogic_ldap/version.rb', line 22 def <=>(version) to_i <=> version.to_i end |
- (Object) to_a
38 39 40 |
# File 'lib/authlogic_ldap/version.rb', line 38 def to_a [@major, @minor, @tiny] end |
- (Object) to_i
Converts this version to a canonical integer that may be compared against other version objects.
34 35 36 |
# File 'lib/authlogic_ldap/version.rb', line 34 def to_i @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny end |
- (Object) 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.
28 29 30 |
# File 'lib/authlogic_ldap/version.rb', line 28 def to_s @to_s ||= [@major, @minor, @tiny].join(".") end |