Class: Fog::Ecloud::MockDataClasses::MockVirtualMachineDisks
- Inherits:
-
Array
- Object
- Array
- Fog::Ecloud::MockDataClasses::MockVirtualMachineDisks
- Defined in:
- lib/fog/compute/ecloud.rb
Instance Method Summary collapse
- #<<(disk) ⇒ Object
- #_parent ⇒ Object
- #at_address(address) ⇒ Object
-
#initialize(parent = nil) ⇒ MockVirtualMachineDisks
constructor
A new instance of MockVirtualMachineDisks.
Constructor Details
#initialize(parent = nil) ⇒ MockVirtualMachineDisks
Returns a new instance of MockVirtualMachineDisks.
573 574 575 |
# File 'lib/fog/compute/ecloud.rb', line 573 def initialize(parent = nil) @parent = parent end |
Instance Method Details
#<<(disk) ⇒ Object
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/fog/compute/ecloud.rb', line 581 def <<(disk) next_address = 0 disk_with_max_address = max {|a, b| a[:address] <=> b[:address] } disk_with_max_address && next_address = disk_with_max_address.address + 1 disk[:address] ||= next_address super(disk) if (addresses = map {|d| d.address }).uniq.size != size raise "Duplicate disk address in: #{addresses.inspect} (#{size})" end sort! {|a, b| a.address <=> b.address } self end |
#_parent ⇒ Object
577 578 579 |
# File 'lib/fog/compute/ecloud.rb', line 577 def _parent @parent end |
#at_address(address) ⇒ Object
597 598 599 |
# File 'lib/fog/compute/ecloud.rb', line 597 def at_address(address) detect {|d| d.address == address } end |