Class: AwsEc2List::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_ec2_list/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ec2: Aws::EC2::Client, region: 'us-east-1', stdout: $stdout) ⇒ Runner

Returns a new instance of Runner.



6
7
8
9
# File 'lib/aws_ec2_list/runner.rb', line 6

def initialize(ec2: Aws::EC2::Client, region: 'us-east-1', stdout: $stdout)
  @ec2 = ec2.new(region: region)
  @stdout = stdout
end

Instance Attribute Details

#ec2Object (readonly)

Returns the value of attribute ec2.



4
5
6
# File 'lib/aws_ec2_list/runner.rb', line 4

def ec2
  @ec2
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



4
5
6
# File 'lib/aws_ec2_list/runner.rb', line 4

def stdout
  @stdout
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
# File 'lib/aws_ec2_list/runner.rb', line 11

def call
  data_header = ["PROJECT", "STACK NAME", "PUBLIC DNS NAME", "LAUNCH TIME", "APP VERSION", "STATE"]
  data = instances.map do |d|
    [d.project, d.stack_name, d.public_dns_name, d.launch_time, d.app_version, d.state]
  end
  data = data.insert(0, data_header)
  stdout.puts Tabularize.it(data, :align => :left).map { |row| row.join ' | ' }
end