class ToBarGraph::StdoutPrint

Public Class Methods

new(bar_graph, stdout=$stdout, show_header: true) click to toggle source
# File lib/stdout_print.rb, line 5
def initialize(bar_graph, stdout=$stdout, show_header: true)
  @bar_graph      = bar_graph
  @stdout         = stdout
  @show_header    = show_header
end

Public Instance Methods

invoke() click to toggle source
# File lib/stdout_print.rb, line 11
def invoke      
  if @bar_graph.length == 0
    @stdout.puts "You have no bar graph data"
  elsif !(@bar_graph.buckets.is_a?(Hash))
    @stdout.puts "The data you have provided is not bargraph-able" 
  else
    print_header if @show_header
    print_body
  end
end

Private Instance Methods

print_body() click to toggle source
print_header() click to toggle source