Title / Description
Code def output_box str, charh, charv, charc stra = (str + "\n ").split("\n") stra.pop strl = stra.max_by{|a| a.length}.length i = 0 puts charc + charh * (strl + 2) + charc while i < stra.length do print "#{charv} " yield stra[i], strl puts " #{charv}" i += 1 end puts charc + charh * (strl + 2) + charc end def fancy_puts_line str output_box(str, "-", "|", "+") {|a, b| print a + " " * (b - a.length)} end def fancy_puts str output_box(str, "#", "#", "#") {|a, b| print a + " " * (b - a.length)} end def fancy_puts_line_center str output_box(str, "-", "|", "+") {|a, b| print a.center b} end def fancy_puts_center str output_box(str, "#", "#", "#") {|a, b| print a.center b} end fancy_puts """! Critical Error ! System resources low!""" fancy_puts_line_center """ Five syllables here Seven more syllables there Are you happy now? """
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code