Method: BCDice::Base.command_pattern
- Defined in:
- lib/bcdice/base.rb
.command_pattern ⇒ Regexp
応答するコマンド全てにマッチする正規表現を返す正規表現を一度生成したら、以後コマンドの登録はできないようにする
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bcdice/base.rb', line 53 def command_pattern @command_pattern ||= nil return @command_pattern if @command_pattern @prefixes ||= [] @prefixes.freeze pattarns = CommonCommand::COMMANDS.map { |c| c::PREFIX_PATTERN.source } + @prefixes @command_pattern = /^S?(#{pattarns.join('|')})/i.freeze end |