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

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

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ MockVirtualMachineDisks

Returns a new instance of MockVirtualMachineDisks.



569
570
571
# File 'lib/fog/ecloud/compute.rb', line 569

def initialize(parent = nil)
  @parent = parent
end

Instance Method Details

#<<(disk) ⇒ Object



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'lib/fog/ecloud/compute.rb', line 577

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



573
574
575
# File 'lib/fog/ecloud/compute.rb', line 573

def _parent
  @parent
end

#at_address(address) ⇒ Object



593
594
595
# File 'lib/fog/ecloud/compute.rb', line 593

def at_address(address)
  detect {|d| d.address == address }
end