Sha256: 82566c235da0bd27babfc8411995ffb6a2412483841acf7220e73703a6aff359
Contents?: true
Size: 1.53 KB
Versions: 4
Compression:
Stored size: 1.53 KB
Contents
class Gestalt class Call attr_accessor :children, :durations attr_accessor :action, :binding, :finished_at, :location, :started_at def initialize(attributes = {}) @started_at = Time.now.to_f for key, value in attributes send("#{key}=", value) end @children ||= [] @durations ||= [] end def ==(other) action == other.action && location == other.location && children == other.children end def display(total, formatador = Formatador.new) data = [] data << format("[bold]%.1f%%[/]", (duration / total) * 100.0) if durations.length > 1 data << "[light_black]#{durations.length}x[/]" end data << "[bold]#{action}[/]" data << "[light_black]#{location}[/]" condensed = [] total = 0.0 for call in children if condensed.last && condensed.last == call condensed.last.durations.concat(call.durations) else condensed << call end total += call.duration end formatador.display_line(data.join(' ')) formatador.indent do for child in condensed child.display(total, formatador) end end end def duration durations.inject(0.0) {|memo, duration| duration + memo} end def durations if @durations.empty? @durations << finished_at - started_at end @durations end def finish @finished_at ||= Time.now.to_f for child in children child.finish end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gestalt-0.0.11 | lib/gestalt/call.rb |
gestalt-0.0.10 | lib/gestalt/call.rb |
gestalt-0.0.9 | lib/gestalt/call.rb |
gestalt-0.0.8 | lib/gestalt/call.rb |