Sha256: 420ddc8c62b0063c479279b1b239a0a2e73613e8a047b34a421be3e6f2ab7934

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# Event Processor
module EVENT

  # Event object.
  class E
    # Event +i+.
    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
    # is event?
    def event?
      if %[#{@event.message}].length > 0 && @event.occurrences.length > 0
        return true
      else
        return false
      end
    end
    # each event occourence 
    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
  end
  # Process event.
  def self.[] k
    E.new(k)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gnu-remind-0.2.5 lib/remind/event.rb
gnu-remind-0.2.3 lib/remind/event.rb