Class: Dependabot::Devbox::Version
- Inherits:
-
Version
- Object
- Version
- Dependabot::Devbox::Version
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/devbox/version.rb
Constant Summary collapse
- LATEST =
"latest"- LATEST_SENTINEL =
A value that sorts above any realistic nixpkgs version, used as the internal representation of the "latest" sentinel since Gem::Version cannot parse the word itself.
T.let("999999", String)
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #inspect ⇒ Object
- #latest? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
34 35 36 37 38 39 |
# File 'lib/dependabot/devbox/version.rb', line 34 def initialize(version) @version_string = T.let(version.to_s.strip, String) @latest = T.let(@version_string == LATEST, T::Boolean) super(@latest ? LATEST_SENTINEL : version) end |
Class Method Details
.correct?(version) ⇒ Boolean
26 27 28 29 30 31 |
# File 'lib/dependabot/devbox/version.rb', line 26 def self.correct?(version) return false if version.nil? return true if version.to_s.strip == LATEST super end |
.new(version) ⇒ Object
42 43 44 |
# File 'lib/dependabot/devbox/version.rb', line 42 def self.new(version) T.cast(super, Dependabot::Devbox::Version) end |
Instance Method Details
#inspect ⇒ Object
57 58 59 |
# File 'lib/dependabot/devbox/version.rb', line 57 def inspect "#<#{self.class} #{@version_string}>" end |
#latest? ⇒ Boolean
47 48 49 |
# File 'lib/dependabot/devbox/version.rb', line 47 def latest? @latest end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/dependabot/devbox/version.rb', line 52 def to_s @version_string end |