Skip to content

Commit fb42e20

Browse files
committed
Creates and closes #30. Implement last <event>, to: <topic> in REPL.
The REPL now supports queries for the last event of a given type to given topic. Examples: ``` last :update, to: 'routes.1B' last :activate, to: 'vehicles.4003' last :depart, to: 'stations.BUS375' ``` This method should make finding relevant events much simpler while using the REPL.
1 parent f7b8182 commit fb42e20

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/repl.rb

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ def call event
3535
def on topic, type, &block
3636
@event_handlers[[topic, type]] = block
3737
end
38+
39+
# Retrieve the last event of the given type published to the given topic.
40+
#
41+
# Example:
42+
# last :update, to: 'vehicles.4002'
43+
def last type, to:
44+
@events[to].find{ |event| event.type == type }
45+
end
3846
end
3947
end
4048
end

0 commit comments

Comments
 (0)