Class: CapEC2::StatusTable
- Inherits:
-
Object
- Object
- CapEC2::StatusTable
show all
- Includes:
- Utils
- Defined in:
- lib/cap-ec2/status-table.rb
Instance Method Summary
collapse
Methods included from Utils
#project_tag, #roles_tag, #stages_tag
Constructor Details
#initialize(instances, ec2_config) ⇒ StatusTable
5
6
7
8
9
|
# File 'lib/cap-ec2/status-table.rb', line 5
def initialize(instances, ec2_config)
@instances = instances
@ec2_config = ec2_config
output
end
|
Instance Method Details
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/cap-ec2/status-table.rb', line 11
def
[
"Num".bold,
"Name".bold,
"ID".bold,
"Type".bold,
"DNS".bold,
"Zone".bold,
"Roles".bold,
"Stages".bold
]
end
|
#instance_to_row(instance, index) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/cap-ec2/status-table.rb', line 39
def instance_to_row(instance, index)
[
sprintf("%02d:", index),
(instance.tags["Name"] || '').green,
instance.id.red,
instance.instance_type.cyan,
instance.contact_point.blue.bold,
instance.availability_zone.magenta,
instance.tags[roles_tag].yellow,
instance.tags[stages_tag].yellow
]
end
|
#output ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/cap-ec2/status-table.rb', line 24
def output
table = Terminal::Table.new(
:style => {
:border_x => "",
:border_i => "",
:border_y => ""
}
)
table.add_row
@instances.each_with_index do |instance,index|
table.add_row instance_to_row(instance, index)
end
puts table.to_s
end
|