Class: Whysoslow::DefaultPrinter
- Inherits:
-
Object
- Object
- Whysoslow::DefaultPrinter
- Defined in:
- lib/whysoslow/default_printer.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ DefaultPrinter
constructor
A new instance of DefaultPrinter.
- #print(thing) ⇒ Object
Constructor Details
#initialize(*args) ⇒ DefaultPrinter
Returns a new instance of DefaultPrinter.
6 7 8 9 10 11 12 13 14 |
# File 'lib/whysoslow/default_printer.rb', line 6 def initialize(*args) @opts, @ios = [ args.last.kind_of?(::Hash) ? args.pop : {}, args.pop || $stdout ] @ios.sync = true @title = @opts[:title] @verbose = @opts[:verbose] end |
Instance Method Details
#print(thing) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/whysoslow/default_printer.rb', line 16 def print(thing) case thing when :title if @title @ios.puts @title.to_s @ios.puts '-'*(@title.to_s.length) end when :run_start @ios.print "whysoslow? " if @verbose when :snapshot @ios.print '.' if @verbose when :run_end @ios.print "\n\n" if @verbose when Whysoslow::Results @ios << snapshots_table(thing) @ios.puts @ios << measurements_table(thing) else end end |