Class: Capistrano::Autoscale::AWS::InstanceCollection

Inherits:
Base
  • Object
show all
Includes:
Enumerable
Defined in:
lib/capistrano/autoscale/aws/instance_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#autoscaling_client, #aws_access_key_id, #aws_autoscale_ami_tags, #aws_autoscale_snapshot_tags, #aws_credentials, #aws_options, #aws_region, #aws_secret_access_key, #ec2_client

Constructor Details

#initialize(ids) ⇒ InstanceCollection

Returns a new instance of InstanceCollection.



11
12
13
14
15
# File 'lib/capistrano/autoscale/aws/instance_collection.rb', line 11

def initialize(ids)
  @instances = query_instances_by_ids(ids).map do |i|
    Instance.new(i.instance_id, i.private_ip_address, i.state.code)
  end
end

Instance Attribute Details

#instancesObject (readonly)

Returns the value of attribute instances.



9
10
11
# File 'lib/capistrano/autoscale/aws/instance_collection.rb', line 9

def instances
  @instances
end

Instance Method Details

#each(&block) ⇒ Object



21
22
23
# File 'lib/capistrano/autoscale/aws/instance_collection.rb', line 21

def each(&block)
  instances.each(&block)
end

#runningObject



17
18
19
# File 'lib/capistrano/autoscale/aws/instance_collection.rb', line 17

def running
  select(&:running?)
end