Sha256: 71bc76da3a0a83cccdb1b1fe5e07785755ee2a52a0050fdedfaf0d2bb1bdefe9

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

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

      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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruboty-ragoon-0.3.1 lib/ruboty/actions/event.rb
ruboty-ragoon-0.3.0 lib/ruboty/actions/event.rb