Class: Spout::Helpers::Version
- Inherits:
-
Object
- Object
- Spout::Helpers::Version
- Defined in:
- lib/spout/helpers/semantic.rb
Overview
Helps to sort semantically versioned numbers to match versions that are close to each other.
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#string ⇒ Object
Returns the value of attribute string.
-
#tiny ⇒ Object
readonly
Returns the value of attribute tiny.
Instance Method Summary collapse
- #build_number ⇒ Object
-
#initialize(string) ⇒ Version
constructor
A new instance of Version.
- #major_number ⇒ Object
- #minor_number ⇒ Object
- #rank ⇒ Object
- #tiny_number ⇒ Object
Constructor Details
#initialize(string) ⇒ Version
Returns a new instance of Version.
11 12 13 14 |
# File 'lib/spout/helpers/semantic.rb', line 11 def initialize(string) @string = string.to_s (@major, @minor, @tiny, @build) = @string.split(".") end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
9 10 11 |
# File 'lib/spout/helpers/semantic.rb', line 9 def build @build end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
9 10 11 |
# File 'lib/spout/helpers/semantic.rb', line 9 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
9 10 11 |
# File 'lib/spout/helpers/semantic.rb', line 9 def minor @minor end |
#string ⇒ Object
Returns the value of attribute string.
8 9 10 |
# File 'lib/spout/helpers/semantic.rb', line 8 def string @string end |
#tiny ⇒ Object (readonly)
Returns the value of attribute tiny.
9 10 11 |
# File 'lib/spout/helpers/semantic.rb', line 9 def tiny @tiny end |
Instance Method Details
#build_number ⇒ Object
28 29 30 |
# File 'lib/spout/helpers/semantic.rb', line 28 def build_number (@build.nil? ? 1 : 0) end |
#major_number ⇒ Object
16 17 18 |
# File 'lib/spout/helpers/semantic.rb', line 16 def major_number @major.to_i end |
#minor_number ⇒ Object
20 21 22 |
# File 'lib/spout/helpers/semantic.rb', line 20 def minor_number @minor.to_i end |
#rank ⇒ Object
32 33 34 |
# File 'lib/spout/helpers/semantic.rb', line 32 def rank [major_number, minor_number, tiny_number, build_number] end |
#tiny_number ⇒ Object
24 25 26 |
# File 'lib/spout/helpers/semantic.rb', line 24 def tiny_number @tiny.to_i end |