Class: EVENT::E

Inherits:
Object
  • Object
show all
Defined in:
lib/remind/event.rb

Overview

Event object.

Instance Method Summary collapse

Constructor Details

#initialize(i) ⇒ E

Event i.



7
8
9
10
11
12
13
14
15
16
# File 'lib/remind/event.rb', line 7

def initialize i
  if @event = Nickel.parse(i)
#        puts %[EVENT event: #{@event}]
    @message = @event.message
  else
#        puts %[EVENT log]
    t = Time.now.utc
    @message = i
  end
end

Instance Method Details

#each(&b) ⇒ Object

each event occourence



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/remind/event.rb', line 26

def each &b
  @event.occurrences.each { |e|
    h = {
      message: @message,
      date: e.start_date.to_date.strftime("%-d %b %Y"),
    }
    if e.start_time
      h[:hour] = e.start_time.to_time.strftime("%k")
      h[:minute] = e.start_time.to_time.strftime("%M")
    else
      h[:hour] = "00"
      h[:minute] = "00"
    end
#        puts %[each message: #{h}]
    b.call(h, e)
  }
  return nil
end

#event?Boolean

is event?

Returns:



18
19
20
21
22
23
24
# File 'lib/remind/event.rb', line 18

def event?
  if %[#{@event.message}].length > 0 && @event.occurrences.length > 0
    return true
  else
    return false
  end
end