class Awspec::Helper::Finder::Subnet::SubnetCache
Usage¶ ↑
Includes Singleton module, so use instance
instead of new
to get a instance.
It is intended to be used internally by the find_subnet
function only.
Many of the methods expect a symbol to search through the cache to avoid having to call to_sym
multiple times.
Public Instance Methods
Source
# File lib/awspec/helper/finder/subnet.rb, line 31 def add_by_cidr(cidr, subnet_id) key_sym = cidr.to_sym @by_cidr[key_sym] = subnet_id.to_sym unless @by_cidr.key?(key_sym) end
Add a mapping of a CIDR to the respective subnet ID
Source
# File lib/awspec/helper/finder/subnet.rb, line 37 def add_by_tag(tag, subnet_id) key_sym = tag.to_sym @by_tag_name[key_sym] = subnet_id.to_sym unless @by_tag_name.key?(key_sym) end
Add a mapping of a tag to the respective subnet ID
Source
# File lib/awspec/helper/finder/subnet.rb, line 44 def add_subnet(subnet) key_sym = subnet.subnet_id.to_sym @subnet_ids[key_sym] = subnet unless @subnet_ids.key?(key_sym) end
Add a Aws::EC2::Types::Subnet
instance to the cache, mapping it’s ID to the instance itself.
Source
# File lib/awspec/helper/finder/subnet.rb, line 80 def empty? @subnet_ids.empty? end
Check if the cache was already initialized or not.
Source
# File lib/awspec/helper/finder/subnet.rb, line 55 def has_cidr?(cidr_symbol) @by_cidr.key?(cidr_symbol) end
Check if a IPv4 CIDR (as a symbol) exists in the cache.
Source
# File lib/awspec/helper/finder/subnet.rb, line 50 def has_subnet?(subnet_id_symbol) @subnet_ids.key?(subnet_id_symbol) end
Check if a subnet ID (as a symbol) exists in the cache.
Source
# File lib/awspec/helper/finder/subnet.rb, line 75 def is_cidr?(subnet_id) @ip_matcher.match(subnet_id) end
Check if a given string looks like a IPv4 CIDR.
Source
# File lib/awspec/helper/finder/subnet.rb, line 60 def subnet_by_cidr(cidr_symbol) @subnet_ids[@by_cidr[cidr_symbol]] end
Return a Aws::EC2::Types::Subnet
that matches the given CIDR.
Source
# File lib/awspec/helper/finder/subnet.rb, line 70 def subnet_by_id(subnet_id_symbol) @subnet_ids[subnet_id_symbol] end
Return a Aws::EC2::Types::Subnet
that matches the given subnet ID.
Source
# File lib/awspec/helper/finder/subnet.rb, line 65 def subnet_by_tag(tag_symbol) @subnet_ids[@by_tag_name[tag_symbol]] end
Return a Aws::EC2::Types::Subnet
that matches the given tag.
Source
# File lib/awspec/helper/finder/subnet.rb, line 85 def to_s "by tag name: #{@by_tag_name}, by CIDR: #{@by_cidr}" end
Return the cache as a string.