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