lib/speed_gun/report.rb in speed_gun-2.0.0.pre.alpha.1 vs lib/speed_gun/report.rb in speed_gun-2.0.0
- old
+ new
@@ -4,10 +4,12 @@
class SpeedGun::Report
# @return [String] Report ID
attr_reader :id
+ attr_accessor :name
+
# @return [Array<SpeedGun::Source>] Profiled source codes
attr_reader :sources
# @return [Array<SpeedGun::Event>] Recorded events
attr_reader :events
@@ -30,10 +32,11 @@
report
end
def initialize
@id = SecureRandom.uuid
+ @name = nil
@sources = []
@events = []
end
def record(event)
@@ -56,9 +59,10 @@
latest_event_finished_at.to_f - nearlest_event_started_at.to_f
end
def to_hash
{
+ name: name,
sources: sources.map { |source| [ source.id, source.to_hash ] },
events: events.map { |event| [event.id, event.to_hash] }
}
end
end