class Eightball
Constants
- RESPONSES
Public Class Methods
Source
# File plugins/eightball.rb, line 52 def self.ask(question = nil, rand: ->(max) { Random.rand(0..max) }) format_response(question, pick_response(rand: rand)) end
Source
# File plugins/eightball.rb, line 12 def self.command_pattern /8ball(?: (.+))?$/i end
Source
# File plugins/eightball.rb, line 45 def self.format_response(question, answer) stripped = question.to_s.strip return answer if stripped.empty? "#{stripped} — #{answer}" end
Source
# File plugins/eightball.rb, line 41 def self.pick_response(rand: ->(max) { Random.rand(0..max) }) RESPONSES[rand.call(RESPONSES.length - 1)] end
Public Instance Methods
Source
# File plugins/eightball.rb, line 56 def ask(question = nil, **options) self.class.ask(question, **options) end
Source
# File plugins/eightball.rb, line 60 def execute(m, question = nil) flood_safe_reply(m, ask(question)) end