Class: Bunup::Values::Version
- Inherits:
-
Object
- Object
- Bunup::Values::Version
- Defined in:
- lib/bunup/values/version.rb
Overview
Parse and handle version strings
Instance Method Summary collapse
- #from_git? ⇒ Boolean
-
#initialize(version_string) ⇒ Version
constructor
A new instance of Version.
- #major ⇒ Object
- #nil? ⇒ Boolean
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(version_string) ⇒ Version
Returns a new instance of Version.
5 6 7 |
# File 'lib/bunup/values/version.rb', line 5 def initialize(version_string) @version_string = version_string end |
Instance Method Details
#from_git? ⇒ Boolean
23 24 25 |
# File 'lib/bunup/values/version.rb', line 23 def from_git? Services::ValidateGitVersion.new(@version_string).perform end |
#major ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/bunup/values/version.rb', line 13 def major if from_git? # '6.0.0.rc2 b6f1d19' => 6 @version_string.split(' ')[0].split('.')[0].to_i else # '6.0.0.rc2' => 6 @version_string.split('.')[0].to_i end end |
#nil? ⇒ Boolean
27 28 29 |
# File 'lib/bunup/values/version.rb', line 27 def nil? @version_string == '' || @version_string.nil? end |
#to_s ⇒ Object
9 10 11 |
# File 'lib/bunup/values/version.rb', line 9 def to_s @version_string end |
#valid? ⇒ Boolean
31 32 33 34 |
# File 'lib/bunup/values/version.rb', line 31 def valid? ::Gem::Version.correct?(@version_string) || Services::ValidateGitVersion.new(@version_string).perform end |