Sha256: 8a3c0a0a45a712f55d7dd4a5806be0f31cb841d5d035c95faf9b817b8fab2f36

Contents?: true

Size: 526 Bytes

Versions: 2

Compression:

Stored size: 526 Bytes

Contents

module Boty
  class ActionDescription
    attr_reader :command, :description
    attr_writer :regex

    def initialize(command, description: nil, regex: nil)
      if description.nil?
        @description = command
      else
        @command = command
        @description = description
      end

      @regex = regex
    end

    def command
      return @command if @command
      return unless @regex
      match = /\?(i?)-(mx|mix):(.*)\)/.match @regex.to_s
      @command = "/#{match[3]}/#{match[1]}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
boty-0.1.2 lib/boty/action_description.rb
boty-0.1.1 lib/boty/action_description.rb