class Ruboty::Xa::Actions::Xa

Constants

XA_LETTERS
XA_MAX_LENGTH

Public Class Methods

new(message) click to toggle source
# File lib/ruboty/xa/actions/xa.rb, line 8
def initialize(message)
  @message = message
end

Public Instance Methods

call() click to toggle source
# File lib/ruboty/xa/actions/xa.rb, line 12
def call
  message.reply(grow_xa)
end

Private Instance Methods

grow_xa() click to toggle source
# File lib/ruboty/xa/actions/xa.rb, line 18
def grow_xa
  keyword = message[:keyword]
  keyword.gsub!(/(。+)/, make_xa)
  keyword.gsub!(/(、+)/, make_xa)
  keyword.gsub!(/(!+)/, make_xa)
  keyword.gsub!(/($)/, make_xa)
  keyword.gsub!(/(\r\n|\r|\n)/, make_xa)
  keyword
end
make_xa() click to toggle source
# File lib/ruboty/xa/actions/xa.rb, line 28
def make_xa
  xa_length.times.inject("") { |xa| xa + XA_LETTERS.sample }
end
xa_length() click to toggle source
# File lib/ruboty/xa/actions/xa.rb, line 32
def xa_length
  rand(XA_MAX_LENGTH) + 1
end