Class: Dependabot::RustToolchain::Version
- Inherits:
-
Version
- Object
- Version
- Dependabot::RustToolchain::Version
- Defined in:
- lib/dependabot/rust_toolchain/version.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dependabot/rust_toolchain/version.rb', line 14 def initialize(version) raise BadRequirementError, "Malformed channel string - string is nil" if version.nil? @version_string = T.let(version.to_s.strip, String) @channel = T.let( Dependabot::RustToolchain::ChannelParser.new(@version_string).parse, T.nilable(Dependabot::RustToolchain::Channel) ) super(@version_string) end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
58 59 60 |
# File 'lib/dependabot/rust_toolchain/version.rb', line 58 def channel @channel end |
Class Method Details
.correct?(version) ⇒ Boolean
32 33 34 35 36 37 38 39 |
# File 'lib/dependabot/rust_toolchain/version.rb', line 32 def self.correct?(version) return false if version.to_s.empty? !Dependabot::RustToolchain::ChannelParser.new(version.to_s).parse.nil? rescue ArgumentError Dependabot.logger.info("Malformed version string #{version}") false end |
.new(version) ⇒ Object
27 28 29 |
# File 'lib/dependabot/rust_toolchain/version.rb', line 27 def self.new(version) T.cast(super, Dependabot::RustToolchain::Version) end |
Instance Method Details
#to_s ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dependabot/rust_toolchain/version.rb', line 42 def to_s return "" if @channel.nil? case @channel.channel_type in ChannelType::Version T.must(@channel.version) in ChannelType::DatedStability "#{@channel.stability}-#{@channel.date}" in ChannelType::Stability T.must(@channel.stability) else "" end end |