Class: BrewCaskTools::Casks::Version
- Inherits:
-
Object
- Object
- BrewCaskTools::Casks::Version
- Defined in:
- lib/bct/cask/version.rb
Overview
Parent class for different types of Versions
Constant Summary collapse
- DIR_BLACKLIST =
['.', '..', '.metadata'].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dir) ⇒ Version
constructor
A new instance of Version.
- #latest? ⇒ Boolean
- #old ⇒ Object
- #rm_old ⇒ Object
- #versions ⇒ Object
Constructor Details
#initialize(dir) ⇒ Version
Returns a new instance of Version.
9 10 11 |
# File 'lib/bct/cask/version.rb', line 9 def initialize(dir) @dir = dir end |
Class Method Details
.parse_version(version) ⇒ Object
30 31 32 33 34 |
# File 'lib/bct/cask/version.rb', line 30 def self.parse_version(version) Versionomy.parse(version) rescue Versionomy::Errors::ParseError version end |
Instance Method Details
#latest? ⇒ Boolean
17 18 19 |
# File 'lib/bct/cask/version.rb', line 17 def latest? all_versions.select { |version| version.to_s == 'latest' }.length.positive? end |
#old ⇒ Object
25 26 27 28 |
# File 'lib/bct/cask/version.rb', line 25 def old _, *previous = versions.reverse previous end |
#rm_old ⇒ Object
21 22 23 |
# File 'lib/bct/cask/version.rb', line 21 def rm_old old.each { |version| rm(version) } end |
#versions ⇒ Object
13 14 15 |
# File 'lib/bct/cask/version.rb', line 13 def versions @versions ||= latest? ? ['latest'] : all_versions.sort end |