Class: AwsEc2List::Runner
- Inherits:
-
Object
- Object
- AwsEc2List::Runner
- Defined in:
- lib/aws_ec2_list/runner.rb
Instance Attribute Summary collapse
-
#ec2 ⇒ Object
readonly
Returns the value of attribute ec2.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ec2: Aws::EC2::Client, region: 'us-east-1', stdout: $stdout) ⇒ Runner
constructor
A new instance of Runner.
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
#ec2 ⇒ Object (readonly)
Returns the value of attribute ec2.
4 5 6 |
# File 'lib/aws_ec2_list/runner.rb', line 4 def ec2 @ec2 end |
#stdout ⇒ Object (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
#call ⇒ Object
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 |