Class: Fog::Vcloud::MockDataClasses::MockVirtualMachineDisks

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

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ MockVirtualMachineDisks

Returns a new instance of MockVirtualMachineDisks.



541
542
543
# File 'lib/fog/vcloud/mock_data_classes.rb', line 541

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

Instance Method Details

#<<(disk) ⇒ Object



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

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



545
546
547
# File 'lib/fog/vcloud/mock_data_classes.rb', line 545

def _parent
  @parent
end

#at_address(address) ⇒ Object



565
566
567
# File 'lib/fog/vcloud/mock_data_classes.rb', line 565

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