Class: Fog::Ecloud::MockDataClasses::MockVirtualMachineDisks

Inherits:
Array
  • Object
show all
Defined in:
lib/fog/compute/ecloud.rb

Instance Method Summary collapse

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

#_parentObject



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