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

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

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ MockVirtualMachineDisks

Returns a new instance of MockVirtualMachineDisks.



542
543
544
# File 'lib/fog/ecloud/mock_data_classes.rb', line 542

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

Instance Method Details

#<<(disk) ⇒ Object



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/fog/ecloud/mock_data_classes.rb', line 550

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



546
547
548
# File 'lib/fog/ecloud/mock_data_classes.rb', line 546

def _parent
  @parent
end

#at_address(address) ⇒ Object



566
567
568
# File 'lib/fog/ecloud/mock_data_classes.rb', line 566

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