Class: Releasetool::Version
- Inherits:
-
Object
- Object
- Releasetool::Version
- Defined in:
- lib/releasetool/version.rb
Instance Attribute Summary collapse
-
#ident ⇒ Object
readonly
Returns the value of attribute ident.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(ident) ⇒ Version
constructor
A new instance of Version.
- #next_major ⇒ Object
- #next_minor ⇒ Object
- #next_patch ⇒ Object
- #to_s ⇒ Object
- #to_s_without_v ⇒ Object
Constructor Details
#initialize(ident) ⇒ Version
Returns a new instance of Version.
7 8 9 10 11 |
# File 'lib/releasetool/version.rb', line 7 def initialize(ident) raise "Not a valid version identifier: #{ident.inspect}" unless ident.is_a?(String) @ident = ident end |
Instance Attribute Details
#ident ⇒ Object (readonly)
Returns the value of attribute ident.
5 6 7 |
# File 'lib/releasetool/version.rb', line 5 def ident @ident end |
Class Method Details
.normalized(major, minor, patch) ⇒ Object
45 46 47 |
# File 'lib/releasetool/version.rb', line 45 def self.normalized(major, minor, patch) new("v#{major}.#{minor}.#{patch}") end |
Instance Method Details
#==(other) ⇒ Object
41 42 43 |
# File 'lib/releasetool/version.rb', line 41 def ==(other) other.is_a?(Releasetool::Version) && ident == other.ident end |
#next_major ⇒ Object
21 22 23 |
# File 'lib/releasetool/version.rb', line 21 def next_major self.class.normalized(incremented(segments[0]), 0, 0) end |
#next_minor ⇒ Object
17 18 19 |
# File 'lib/releasetool/version.rb', line 17 def next_minor self.class.normalized(segments[0], incremented(segments[1]), 0) end |
#next_patch ⇒ Object
13 14 15 |
# File 'lib/releasetool/version.rb', line 13 def next_patch self.class.normalized(segments[0], segments[1], incremented(segments[2])) end |
#to_s ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/releasetool/version.rb', line 25 def to_s if @ident[0] == "v" @ident else "v#{@ident}" end end |
#to_s_without_v ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/releasetool/version.rb', line 33 def to_s_without_v if @ident[0] == "v" @ident[1..-1] else @ident end end |