Class: Bosh::Cli::NameVersionPair
- Defined in:
- lib/cli/name_version_pair.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, version) ⇒ NameVersionPair
constructor
A new instance of NameVersionPair.
Constructor Details
#initialize(name, version) ⇒ NameVersionPair
Returns a new instance of NameVersionPair.
18 19 20 |
# File 'lib/cli/name_version_pair.rb', line 18 def initialize(name, version) @name, @version = name, version end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/cli/name_version_pair.rb', line 16 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
16 17 18 |
# File 'lib/cli/name_version_pair.rb', line 16 def version @version end |
Class Method Details
.parse(str) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/cli/name_version_pair.rb', line 4 def self.parse(str) raise ArgumentError, 'str must not be nil' if str.nil? #raise ArgumentError, 'str must not be empty' if str.empty? name, _, version = str.rpartition('/') if name.empty? || version.empty? raise ArgumentError, "\"#{str}\" must be in the form name/version" end new(name, version) end |