Class: Bosh::Cli::NameIdPair
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, id) ⇒ NameIdPair
constructor
A new instance of NameIdPair.
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
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'lib/cli/name_id_pair.rb', line 15 def id @id end |
#name ⇒ Object (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
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 |