Class: Wisper::Visualize::RecordingBroadcaster
- Inherits:
-
Object
- Object
- Wisper::Visualize::RecordingBroadcaster
- Defined in:
- lib/wisper/visualize/recording_broadcaster.rb
Defined Under Namespace
Classes: Event
Instance Method Summary collapse
- #broadcast(subscriber, publisher, event, args) ⇒ Object
- #events ⇒ Object
-
#flattened_events ⇒ Object
de-duplicates events and increments frequency for each duplicate FIXME: ugly…
-
#initialize(broadcaster) ⇒ RecordingBroadcaster
constructor
A new instance of RecordingBroadcaster.
Constructor Details
#initialize(broadcaster) ⇒ RecordingBroadcaster
Returns a new instance of RecordingBroadcaster.
4 5 6 7 |
# File 'lib/wisper/visualize/recording_broadcaster.rb', line 4 def initialize(broadcaster) @events = [] @broadcaster = broadcaster end |
Instance Method Details
#broadcast(subscriber, publisher, event, args) ⇒ Object
9 10 11 12 |
# File 'lib/wisper/visualize/recording_broadcaster.rb', line 9 def broadcast(subscriber, publisher, event, args) @broadcaster.broadcast(subscriber, publisher, event, args) @events.push(Event.new(subscriber, publisher, event, args)) end |
#events ⇒ Object
14 15 16 |
# File 'lib/wisper/visualize/recording_broadcaster.rb', line 14 def events @events.dup end |
#flattened_events ⇒ Object
de-duplicates events and increments frequency for each duplicate FIXME: ugly…
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wisper/visualize/recording_broadcaster.rb', line 20 def flattened_events _result = [] _events = events while event = _events.pop do match = _events.find { |e| e == event } if match.nil? _result << event else match.increment_frequency end end _result end |