Class: Dependabot::Pub::Version
- Inherits:
-
Version
- Object
- Version
- Dependabot::Pub::Version
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/pub/version.rb
Constant Summary collapse
- VERSION_PATTERN =
T.let(Gem::Version::VERSION_PATTERN + "(\\+[0-9a-zA-Z\\-.]+)?", String)
- ANCHORED_VERSION_PATTERN =
/\A\s*(#{VERSION_PATTERN})?\s*\z/
Instance Attribute Summary collapse
-
#build_info ⇒ Object
readonly
Returns the value of attribute build_info.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
-
#inspect ⇒ Object
:nodoc:.
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
31 32 33 34 35 36 37 38 |
# File 'lib/dependabot/pub/version.rb', line 31 def initialize(version) @version_string = T.let(version.to_s, String) @build_info = T.let(nil, T.nilable(String)) version, @build_info = version.to_s.split("+") if version.to_s.include?("+") super(T.must(version)) end |
Instance Attribute Details
#build_info ⇒ Object (readonly)
Returns the value of attribute build_info.
28 29 30 |
# File 'lib/dependabot/pub/version.rb', line 28 def build_info @build_info end |
Class Method Details
.correct?(version) ⇒ Boolean
56 57 58 59 60 |
# File 'lib/dependabot/pub/version.rb', line 56 def self.correct?(version) return false if version.nil? version.to_s.match?(ANCHORED_VERSION_PATTERN) end |
.new(version) ⇒ Object
41 42 43 |
# File 'lib/dependabot/pub/version.rb', line 41 def self.new(version) T.cast(super, Dependabot::Pub::Version) end |
Instance Method Details
#inspect ⇒ Object
:nodoc:
51 52 53 |
# File 'lib/dependabot/pub/version.rb', line 51 def inspect # :nodoc: "#<#{self.class} #{@version_string}>" end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/dependabot/pub/version.rb', line 46 def to_s @version_string end |