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

- (MockVirtualMachineDisks) initialize(parent = nil)

Returns a new instance of MockVirtualMachineDisks



540
541
542
# File 'lib/fog/ecloud/mock_data_classes.rb', line 540

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

Instance Method Details

- (Object) <<(disk)



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

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

- (Object) _parent



544
545
546
# File 'lib/fog/ecloud/mock_data_classes.rb', line 544

def _parent
  @parent
end

- (Object) at_address(address)



564
565
566
# File 'lib/fog/ecloud/mock_data_classes.rb', line 564

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