Sha256: acdfb1b172f3693ddcc7366f66896588877cc3400ee4b9d95e9c81c33b853f6c

Contents?: true

Size: 597 Bytes

Versions: 11

Compression:

Stored size: 597 Bytes

Contents

module Ruboty::Actions::Ragoon
  class Event < ::Ruboty::Actions::Base
    include ::Ruboty::Actions::Ragoon

    def call
      target_date = parse_date(message[:date])
      events = ::Ruboty::Ragoon::Event.new(target_date)
      message.reply(events.render(private: private?))
    end

    private

    def parse_date(date)
      date = date.strip.downcase
      case date
      when 'today'
        Date.today
      when 'tomorrow'
        Date.today + 1
      when 'yesterday'
        Date.today - 1
      else
        Date.parse(date)
      end
    rescue
      Date.today
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruboty-ragoon-1.1.0 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-1.0.0 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.8.1 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.8.0 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.7.0 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.6.1 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.6.0 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.5.2 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.5.1 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.5.0 lib/ruboty/actions/ragoon/event.rb
ruboty-ragoon-0.4.0 lib/ruboty/actions/ragoon/event.rb