Class: Aws::Partitions::PartitionList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aws-partitions/partition_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePartitionList

Returns a new instance of PartitionList.



7
8
9
# File 'lib/aws-partitions/partition_list.rb', line 7

def initialize
  @partitions = {}
end

Class Method Details

.build(partitions) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



52
53
54
55
56
57
# File 'lib/aws-partitions/partition_list.rb', line 52

def build(partitions)
  partitions['partitions'].inject(PartitionList.new) do |list, partition|
    list.add_partition(Partition.build(partition))
    list
  end
end

Instance Method Details

#add_partition(partition) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:



35
36
37
38
39
40
41
# File 'lib/aws-partitions/partition_list.rb', line 35

def add_partition(partition)
  if Partition === partition
    @partitions[partition.name] = partition
  else
    raise ArgumentError, "expected Partition, got #{partition.class}"
  end
end

#clearObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Removed all partitions.



45
46
47
# File 'lib/aws-partitions/partition_list.rb', line 45

def clear
  @partitions = {}
end

#each(&block) ⇒ Enumerator<Partition>

Returns:



12
13
14
# File 'lib/aws-partitions/partition_list.rb', line 12

def each(&block)
  @partitions.each_value(&block)
end

#partition(partition_name) ⇒ Partition

Parameters:

  • partition_name (String)

Returns:



18
19
20
21
22
23
24
25
26
# File 'lib/aws-partitions/partition_list.rb', line 18

def partition(partition_name)
  if @partitions.key?(partition_name)
    @partitions[partition_name]
  else
    msg = "invalid partition name #{partition_name.inspect}; valid "
    msg << "partition names include %s" % [@partitions.keys.join(', ')]
    raise ArgumentError, msg
  end
end

#partitionsArray<Partition>

Returns:



29
30
31
# File 'lib/aws-partitions/partition_list.rb', line 29

def partitions
  @partitions.values
end