Class: Hubkit::EventCollection
- Inherits:
-
ChainableCollection
- Object
- ChainableCollection
- Hubkit::EventCollection
- Defined in:
- lib/hubkit/event_collection.rb
Overview
A collection of GitHub events with chainable filters
Instance Method Summary collapse
-
#between(start_dt, end_date) ⇒ EventCollection
Filter to all the events which occur between start_dt and end_date, inclusive.
-
#chronological ⇒ EventCollection
Put the list of events in chronological order.
-
#closed ⇒ EventCollection
Filter to all events where an issue was closed.
-
#labeled(label) ⇒ EventCollection
Filter to all events where an issue was labeled with a given label.
-
#reverse_chronological ⇒ EventCollection
Put the list of events in reverse chronological order.
Methods inherited from ChainableCollection
#==, #initialize, #method_missing, #not, #respond_to?, scope, #select, #wrap
Constructor Details
This class inherits a constructor from Hubkit::ChainableCollection
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hubkit::ChainableCollection
Instance Method Details
#between(start_dt, end_date) ⇒ EventCollection
Filter to all the events which occur between start_dt and end_date, inclusive
29 30 31 32 33 34 35 36 |
# File 'lib/hubkit/event_collection.rb', line 29 def between(start_dt, end_date) wrap( @inner.select do |event| stamp = Time.parse(event['created_at']) stamp >= start_dt && stamp <= end_date end, ) end |
#chronological ⇒ EventCollection
Put the list of events in chronological order
16 17 18 19 20 21 22 |
# File 'lib/hubkit/event_collection.rb', line 16 def chronological wrap( sort do |a, b| Time.parse(a['created_at']) <=> Time.parse(b['created_at']) end, ) end |
#closed ⇒ EventCollection
Filter to all events where an issue was closed
54 55 56 |
# File 'lib/hubkit/event_collection.rb', line 54 def closed wrap(@inner.select { |event| event.event == 'closed' }) end |
#labeled(label) ⇒ EventCollection
Filter to all events where an issue was labeled with a given label
42 43 44 45 46 47 48 49 |
# File 'lib/hubkit/event_collection.rb', line 42 def labeled(label) wrap( @inner.select do |event| event['event'] == 'labeled' && event['label'].name.downcase == label.downcase end, ) end |
#reverse_chronological ⇒ EventCollection
Put the list of events in reverse chronological order
6 7 8 9 10 11 12 |
# File 'lib/hubkit/event_collection.rb', line 6 def reverse_chronological wrap( sort do |a, b| Time.parse(b['created_at']) <=> Time.parse(a['created_at']) end, ) end |