Class: AwsRo::EC2::Repository::Relation

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/aws_ro/ec2/repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Relation

Returns a new instance of Relation.



60
61
62
63
64
# File 'lib/aws_ro/ec2/repository.rb', line 60

def initialize(klass)
  @klass = klass
  @filters = []
  @instance_ids = []
end

Instance Method Details

#filters(filters) ⇒ Object



76
77
78
79
# File 'lib/aws_ro/ec2/repository.rb', line 76

def filters(filters)
  @filters += filters
  self
end

#instance_ids(ids) ⇒ Object



66
67
68
69
# File 'lib/aws_ro/ec2/repository.rb', line 66

def instance_ids(ids)
  @instance_ids += ids
  self
end

#not_terminatedObject



86
87
88
89
90
# File 'lib/aws_ro/ec2/repository.rb', line 86

def not_terminated
  @filters << { name: 'instance-state-name',
                values: ['pending', 'running', 'shutting-down', 'stopping', 'stopped'] }
  self
end

#runningObject



81
82
83
84
# File 'lib/aws_ro/ec2/repository.rb', line 81

def running
  @filters << { name: 'instance-state-name', values: ['running'] }
  self
end

#tags(filter_hash = {}) ⇒ Object



71
72
73
74
# File 'lib/aws_ro/ec2/repository.rb', line 71

def tags(filter_hash = {})
  @filters += hash_to_tags_array(filter_hash)
  self
end

#to_aObject Also known as: force, inspect, all



92
93
94
# File 'lib/aws_ro/ec2/repository.rb', line 92

def to_a
  fetch
end