module Pleiades::Command::Routing::EventJudgeMethods

Private Instance Methods

convert_to_reg(id) click to toggle source
# File lib/pleiades/core/command/routing/event_judge_methods.rb, line 35
def convert_to_reg(id)
  case id
  when String, Integer
    return '*'.eql?(id) ? /^\d+$/ : /^#{id}$/
  when Array
    return /^#{id.join('|')}$/
  end
  id
end
judge_method(event) click to toggle source
# File lib/pleiades/core/command/routing/event_judge_methods.rb, line 13
def judge_method(event)
  :"judge_#{event}"
end
judge_method_defined?(method_name) click to toggle source
# File lib/pleiades/core/command/routing/event_judge_methods.rb, line 7
def judge_method_defined?(method_name)
  Pleiades::Command::Routing::EventJudgeMethods
    .private_instance_methods(false)
    .include?(judge_method(method_name))
end
judge_postback(args) click to toggle source
# File lib/pleiades/core/command/routing/event_judge_methods.rb, line 45
def judge_postback(args)
  normalize_path(args[:scope], args[:action]) == @event.action
end
judge_sticker(args) click to toggle source
# File lib/pleiades/core/command/routing/event_judge_methods.rb, line 29
def judge_sticker(args)
  p_id, s_id = @event.sticker_ids
  convert_to_reg(args[:package_id]) =~ p_id &&
    convert_to_reg(args[:sticker_id]) =~ s_id
end
judge_text(args) click to toggle source
# File lib/pleiades/core/command/routing/event_judge_methods.rb, line 17
def judge_text(args)
  pattern =
    case args[:pattern]
    when Regexp
      args[:pattern]
    when String
      /^#{args[:pattern]}$/
    end

  pattern =~ @event.text
end