2013-07-08 1 views
0

임 : 선택적인 트윗을 허용 및 차단하고 'does_match?'에서만 표시하는 데 어려움을 겪고 있습니다.Ruby 정규식 선택 트위스트

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 
+1

어떤 문제가 있습니까? 데이터 입/출력은 어떤 모습입니까? – squiguy

+2

순간에는 출력이 입력과 동일합니다 – drewsdesign

답변

0

첫째, 당신은 문자열 의 리턴으로 아무것도하지 않고 봇 대신

allow = /orange|grape\sfruit|apple/ 

가 둘째, 당신은 몇 가지 일치 값들하고있는이 작업을 수행으로 귀하의 regexps '에 정의되어있다 이

if @tweet.match(allow) 
    # rest of logic 
    # checking blocked and allowed for user 
    @tweet # or true 
else 
    nil # or false 
end 
+0

환상 감사합니다! – drewsdesign