Class: Fiveruns::Dash::Rails::Version
- Inherits:
-
Object
- Object
- Fiveruns::Dash::Rails::Version
- Includes:
- Comparable
- Defined in:
- lib/fiveruns/dash/rails/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 collapse
- PARSED =
YAML.load(File.read(File.dirname(__FILE__) << "/../../../../version.yml"))
- MAJOR =
- MINOR =
- TINY =
- 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
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#tiny ⇒ Object
readonly
Returns the value of attribute tiny.
Class Method Summary collapse
-
.[](major, minor, tiny) ⇒ Object
A convenience method for instantiating a new Version instance with the given
major,minor, andtinycomponents. -
.rails ⇒ Object
Borrowed from TuneUp.
Instance Method Summary collapse
-
#<=>(version) ⇒ Object
Compare this version to the given
versionobject. -
#initialize(major, minor, tiny) ⇒ Version
constructor
Create a new Version object with the given components.
- #to_a ⇒ Object
-
#to_i ⇒ Object
Converts this version to a canonical integer that may be compared against other version objects.
-
#to_s ⇒ Object
Converts this version object to a string, where each of the three version components are joined by the ‘.’ character.
Constructor Details
#initialize(major, minor, tiny) ⇒ Version
Create a new Version object with the given components.
55 56 57 |
# File 'lib/fiveruns/dash/rails/version.rb', line 55 def initialize(major, minor, tiny) @major, @minor, @tiny = major, minor, tiny end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
52 53 54 |
# File 'lib/fiveruns/dash/rails/version.rb', line 52 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
52 53 54 |
# File 'lib/fiveruns/dash/rails/version.rb', line 52 def minor @minor end |
#tiny ⇒ Object (readonly)
Returns the value of attribute tiny.
52 53 54 |
# File 'lib/fiveruns/dash/rails/version.rb', line 52 def tiny @tiny end |
Class Method Details
.[](major, minor, tiny) ⇒ Object
A convenience method for instantiating a new Version instance with the given major, minor, and tiny components.
39 40 41 |
# File 'lib/fiveruns/dash/rails/version.rb', line 39 def self.[](major, minor, tiny) new(major, minor, tiny) end |
Instance Method Details
#<=>(version) ⇒ Object
Compare this version to the given version object.
60 61 62 |
# File 'lib/fiveruns/dash/rails/version.rb', line 60 def <=>(version) to_i <=> version.to_i end |
#to_a ⇒ Object
76 77 78 |
# File 'lib/fiveruns/dash/rails/version.rb', line 76 def to_a [@major, @minor, @tiny] end |
#to_i ⇒ Object
Converts this version to a canonical integer that may be compared against other version objects.
72 73 74 |
# File 'lib/fiveruns/dash/rails/version.rb', line 72 def to_i @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny end |
#to_s ⇒ Object
Converts this version object to a string, where each of the three version components are joined by the ‘.’ character. E.g., 2.0.0.
66 67 68 |
# File 'lib/fiveruns/dash/rails/version.rb', line 66 def to_s @to_s ||= [@major, @minor, @tiny].join(".") end |