0

.match を使用して選択的なツイートのみを許可およびブロックし、「does_match?」からのツイートのみを表示するのに苦労しています。

  def does_match?
    allow = "/orange|grape\sfruit|apple/"
    block = "/@fruits|coconut/"
    allowfruits = "/berry|mango/"

    @tweet.match(allow).nil?
    @tweet.match(block)
    @tweet.match(allowfruits) if @user =~ /\A(twitteruser|anotheraccount)\Z/
    @tweet.match(/@[A-Za-z0-9_:-]+/)
    return @tweet
  end

  def show
    return @tweet
  end
4

1 に答える 1

0

まず、正規表現を文字列として定義していますが、代わりにこれを行います

allow = /orange|grape\sfruit|apple/

第二に、あなたはいくつかのマッチボットをやっていて、その戻り値で何もしていません。

if @tweet.match(allow)
   # rest of logic
   # checking blocked and allowed for user
   @tweet # or true
else
   nil # or false
end
于 2013-07-08T09:38:40.033 に答える