Class: Bosh::Cli::NameIdPair

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id) ⇒ NameIdPair

Returns a new instance of NameIdPair.



17
18
19
# File 'lib/cli/name_id_pair.rb', line 17

def initialize(name, id)
  @name, @id = name, id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/cli/name_id_pair.rb', line 15

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/cli/name_id_pair.rb', line 15

def name
  @name
end

Class Method Details

.parse(str) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
12
13
# File 'lib/cli/name_id_pair.rb', line 4

def self.parse(str)
  raise ArgumentError, 'str must not be nil' if str.nil?

  name, _, id = str.rpartition('/')
  if name.empty? || id.empty?
    raise ArgumentError, "\"#{str}\" must be in the form name/id"
  end

  new(name, id)
end