Sha256: 0a734c5f179e6157c68b091920afa4e4175989cdcf8e7ff57f5b668293fea9bc

Contents?: true

Size: 527 Bytes

Versions: 1

Compression:

Stored size: 527 Bytes

Contents

module Lita
  module Handlers
    class Doubler < Handler
      # insert handler code here
      route(
        /^double\s+(\d+)$/i,
        :respond_with_double,
        command: true,
        help: { 'double N' => 'prints N + N' }
      )

      Lita.register_handler(self)

      def double_number(n)
        n + n
      end

      def respond_with_double(response)
        n = response.match_data.captures.first
        n = Integer(n)

        response.reply "#{n} + #{n} = #{double_number n}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-doubler-lcpp-0.1.1 lib/lita/handlers/doubler.rb