class CapEC2::StatusTable
Public Class Methods
new(instances)
click to toggle source
# File lib/cap-ec2/status-table.rb, line 5 def initialize(instances) @instances = instances output end
Public Instance Methods
header_row()
click to toggle source
# File lib/cap-ec2/status-table.rb, line 10 def header_row [ bold("Num"), bold("Name"), bold("ID"), bold("Type"), bold("DNS"), bold("Zone"), bold("Roles"), bold("Stages") ] end
instance_to_row(instance, index)
click to toggle source
# File lib/cap-ec2/status-table.rb, line 38 def instance_to_row(instance, index) [ sprintf("%02d:", index), green(tag_value(instance, 'Name') || ''), red(instance.instance_id), cyan(instance.instance_type), bold(blue(CapEC2::Utils.contact_point(instance))), magenta(instance.placement.availability_zone), yellow(tag_value(instance, roles_tag)), yellow(tag_value(instance, stages_tag)) ] end
output()
click to toggle source
# File lib/cap-ec2/status-table.rb, line 23 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