Class: AwsInstanceList::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_instance_list/base.rb

Direct Known Subclasses

ElastiCache, ElasticsearchService, RDS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region: 'eu-west-1') ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
# File 'lib/aws_instance_list/base.rb', line 9

def initialize region: 'eu-west-1'

  @region=region

  @metric = AwsInstanceList::Metric.new region: region

  @instances = []

end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/aws_instance_list/base.rb', line 7

def client
  @client
end

#metricObject

Returns the value of attribute metric.



7
8
9
# File 'lib/aws_instance_list/base.rb', line 7

def metric
  @metric
end

#regionObject

Returns the value of attribute region.



7
8
9
# File 'lib/aws_instance_list/base.rb', line 7

def region
  @region
end

Instance Method Details

#demodulizeObject



42
43
44
# File 'lib/aws_instance_list/base.rb', line 42

def demodulize
  self.class.name.split('::').last
end

#instances(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/aws_instance_list/base.rb', line 19

def instances options={}
  ds=descriptions(options)
  @instances+=ds.send( list_method )
  if ds.marker
    options[:marker]=ds.marker
    instances(options)
  else
    @instances
  end
end

#yamlObject



30
31
32
# File 'lib/aws_instance_list/base.rb', line 30

def yaml
  @yaml||=yaml_default.merge(yaml_file)[demodulize]
end

#yaml_defaultObject



34
35
36
# File 'lib/aws_instance_list/base.rb', line 34

def yaml_default
  YAML.load_file AwsInstanceList::DEFAULT_SETTINGS
end

#yaml_fileObject



38
39
40
# File 'lib/aws_instance_list/base.rb', line 38

def yaml_file
  ENV.has_key?('AWS_INSTANCE_LIST_YAML') ? YAML.load_file(ENV['AWS_INSTANCE_LIST_YAML']) : {}
end