Skip to content

Commit

Permalink
Creates and closes #30. Implement last <event>, to: <topic> in REPL.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
faultyserver committed Sep 22, 2016
1 parent f7b8182 commit fb42e20
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/repl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def call event
def on topic, type, &block
@event_handlers[[topic, type]] = block
end

# Retrieve the last event of the given type published to the given topic.
#
# Example:
# last :update, to: 'vehicles.4002'
def last type, to:
@events[to].find{ |event| event.type == type }
end
end
end
end

0 comments on commit fb42e20

Please sign in to comment.