Class: ChefCLI::PolicyfileServices::ShowPolicy::ReportPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-cli/policyfile_services/show_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ui) ⇒ ReportPrinter

Returns a new instance of ReportPrinter.



29
30
31
# File 'lib/chef-cli/policyfile_services/show_policy.rb', line 29

def initialize(ui)
  @ui = ui
end

Instance Attribute Details

#uiObject (readonly)

Returns the value of attribute ui.



27
28
29
# File 'lib/chef-cli/policyfile_services/show_policy.rb', line 27

def ui
  @ui
end

Instance Method Details

#h1(heading) ⇒ Object



33
34
35
36
37
# File 'lib/chef-cli/policyfile_services/show_policy.rb', line 33

def h1(heading)
  ui.msg(heading)
  ui.msg("=" * heading.size)
  ui.msg("")
end

#h2(heading) ⇒ Object



39
40
41
42
43
# File 'lib/chef-cli/policyfile_services/show_policy.rb', line 39

def h2(heading)
  ui.msg(heading)
  ui.msg("-" * heading.size)
  ui.msg("")
end

#list(items) ⇒ Object



55
56
57
58
# File 'lib/chef-cli/policyfile_services/show_policy.rb', line 55

def list(items)
  items.each { |item| ui.msg("* #{item}") }
  ui.msg("")
end

#table_list(items) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/chef-cli/policyfile_services/show_policy.rb', line 45

def table_list(items)
  left_justify_size = items.keys.map(&:size).max.to_i + 2
  items.each do |name, value|
    justified_name = "#{name}:".ljust(left_justify_size)
    ui.msg("* #{justified_name} #{value}")
  end

  ui.msg("")
end