Sha256: 941fb42dd3d844f2d2d72c16f01efc14c5dfebc83dd770011a92a62d5f01bc9e

Contents?: true

Size: 493 Bytes

Versions: 1

Compression:

Stored size: 493 Bytes

Contents

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

      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

      Lita.register_handler(self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-doubler-iamarmanjon-0.1.0 lib/lita/handlers/doubler.rb