Class: VagrantPlugins::Utm::Model::ListResult
- Inherits:
-
Object
- Object
- VagrantPlugins::Utm::Model::ListResult
- Defined in:
- lib/vagrant_utm/model/list_result.rb
Overview
Represents the result of a ‘utmctl list’ operation.
Defined Under Namespace
Classes: ListResultItem
Instance Attribute Summary collapse
-
#machines ⇒ Array<ListResultItem>
The list of machines.
Instance Method Summary collapse
-
#any?(uuid) ⇒ Boolean
Checks if a machine with the given UUID exists.
-
#find(name: nil, uuid: nil) ⇒ ListResultItem
Finds a machine with the given name or uuid.
-
#initialize(data) ⇒ ListResult
constructor
Initialize the result from raw data.
-
#last ⇒ ListResultItem
Return the last machine in the list.
Constructor Details
#initialize(data) ⇒ ListResult
Initialize the result from raw data.
13 14 15 16 17 18 19 |
# File 'lib/vagrant_utm/model/list_result.rb', line 13 def initialize(data) @machines = [] data.each do |machine| item = ListResultItem.new(machine) @machines << item end end |
Instance Attribute Details
#machines ⇒ Array<ListResultItem>
Returns The list of machines.
9 10 11 |
# File 'lib/vagrant_utm/model/list_result.rb', line 9 def machines @machines end |
Instance Method Details
#any?(uuid) ⇒ Boolean
Checks if a machine with the given UUID exists.
24 25 26 |
# File 'lib/vagrant_utm/model/list_result.rb', line 24 def any?(uuid) @machines.any? { |i| i.uuid == uuid } end |
#find(name: nil, uuid: nil) ⇒ ListResultItem
Finds a machine with the given name or uuid.
31 32 33 34 35 36 37 |
# File 'lib/vagrant_utm/model/list_result.rb', line 31 def find(name: nil, uuid: nil) if name @machines.find { |i| i.name == name } elsif uuid @machines.find { |i| i.uuid == uuid } end end |
#last ⇒ ListResultItem
Return the last machine in the list.
41 42 43 |
# File 'lib/vagrant_utm/model/list_result.rb', line 41 def last @machines.last end |