Class: LiquidProf::Reporter
- Inherits:
-
Object
- Object
- LiquidProf::Reporter
- Defined in:
- lib/liquidprof/reporter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#prof ⇒ Object
readonly
Returns the value of attribute prof.
Instance Method Summary collapse
- #format_bytes(bytes) ⇒ Object
-
#initialize(prof) ⇒ Reporter
constructor
A new instance of Reporter.
- #summarize_stats(template) ⇒ Object
Constructor Details
#initialize(prof) ⇒ Reporter
Returns a new instance of Reporter.
5 6 7 |
# File 'lib/liquidprof/reporter.rb', line 5 def initialize(prof) @prof = prof end |
Instance Attribute Details
#prof ⇒ Object (readonly)
Returns the value of attribute prof.
3 4 5 |
# File 'lib/liquidprof/reporter.rb', line 3 def prof @prof end |
Instance Method Details
#format_bytes(bytes) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/liquidprof/reporter.rb', line 18 def format_bytes(bytes) units = ["B", "K", "M"] if bytes.to_i < 1024 exponent = 0 else exponent = (Math.log(bytes)/Math.log(1024)).to_i bytes /= 1024 ** [exponent, units.size].min end if exponent == 0 "#{bytes.to_i}#{units[exponent]}" else "%.2f%s" % [ bytes, units[exponent] ] end end |