Class: Bosh::Cli::NameVersionPair

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/name_version_pair.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/cli/name_version_pair.rb', line 16

def name
  @name
end

#versionObject (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

Raises:

  • (ArgumentError)


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