Module: Kernel
- Defined in:
- lib/bruce-banner.rb
Overview
this is where the magic happens…
Instance Method Summary collapse
-
#bb(what = "", options = {}, &block) ⇒ Object
block magic shamelessly stolen from Jim Weirich (with a small tweak) www.justskins.com/forums/print-out-a-variables-101209.html.
Instance Method Details
#bb(what = "", options = {}, &block) ⇒ Object
block magic shamelessly stolen from Jim Weirich (with a small tweak) www.justskins.com/forums/print-out-a-variables-101209.html
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bruce-banner.rb', line 48 def bb(what="", ={}, &block) = BruceBanner.defaults.merge() if block_given? name = block.call.to_s what = "#{name}: #{eval(name, block.binding)}" end if [:size_to_fit] [:count] = [what.to_s.size, BruceBanner.defaults[:maximum]].min end output = [] output << ([:string] * [:count]) if [:before] output << "#{what}" output << ([:string] * [:count]) if [:after] puts output.join("\n") end |