Class: Ruboty::Ragoon::Remind
- Inherits:
-
Object
- Object
- Ruboty::Ragoon::Remind
- Includes:
- NotifyOnce
- Defined in:
- lib/ruboty/ragoon/remind.rb
Constant Summary collapse
- NOTIFY_BEFORE_EVENT_START =
minutes before start_at
3
Instance Attribute Summary collapse
-
#brain ⇒ Object
readonly
Returns the value of attribute brain.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
Instance Method Summary collapse
-
#initialize(brain) ⇒ Remind
constructor
A new instance of Remind.
- #retrieve ⇒ Object
Methods included from NotifyOnce
Constructor Details
#initialize(brain) ⇒ Remind
Returns a new instance of Remind.
9 10 11 |
# File 'lib/ruboty/ragoon/remind.rb', line 9 def initialize(brain) @brain = brain end |
Instance Attribute Details
#brain ⇒ Object (readonly)
Returns the value of attribute brain.
5 6 7 |
# File 'lib/ruboty/ragoon/remind.rb', line 5 def brain @brain end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
5 6 7 |
# File 'lib/ruboty/ragoon/remind.rb', line 5 def event @event end |
Instance Method Details
#retrieve ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruboty/ragoon/remind.rb', line 13 def retrieve now = Time.now.localtime @event = Event.new @event.filter_events do |event| begin event_start = Time.parse(event[:start_at]).localtime event_start.between?(now, now + NOTIFY_BEFORE_EVENT_START * 60) rescue false end end new_event_ids = not_notified_ids(@event.events.map { |event| event[:id] }) @event.filter_events do |event| new_event_ids.include?(event[:id]) end @event end |