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.



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

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

Instance Method Details

#<<(disk) ⇒ Object



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

#_parentObject



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

def _parent
  @parent
end

#at_address(address) ⇒ Object



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

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