Class: Moonshot::StackParameterPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/moonshot/stack_parameter_printer.rb

Overview

Displays information about existing stack parameters to the user, with information on what a stack update would do.

Instance Method Summary collapse

Constructor Details

#initialize(stack, table) ⇒ StackParameterPrinter

Returns a new instance of StackParameterPrinter.



7
8
9
10
# File 'lib/moonshot/stack_parameter_printer.rb', line 7

def initialize(stack, table)
  @stack = stack
  @table = table
end

Instance Method Details

#format_value(value) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/moonshot/stack_parameter_printer.rb', line 21

def format_value(value)
  if value.size > 60
    "#{value[0..60]}..."
  else
    value
  end
end


12
13
14
15
16
17
18
19
# File 'lib/moonshot/stack_parameter_printer.rb', line 12

def print
  p_table = @table.add_leaf('Stack Parameters')
  rows = @stack.parameters.sort.map do |key, value|
    ["#{key}:", format_value(value)]
  end

  p_table.add_table(rows)
end