Forum: Ruby code snippet: can it be done better/shorter?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Krekna M. (Guest)
on 2006-03-01 17:25
(Received via mailing list)
AFAIC See, this works all right, but my question is, just to learn the
Ruby style,
can this be done shorter (better)?

class LineChecker
  def checkline(line)
      if line =~ /Checking:/
         line =~ /<(.*?)>.*<(.*)>/
         from = $1; rcpt = $2
         from = "Unknown" if from == ""
         rcpt = "Unknown" if rcpt == ""
         return ([from,rcpt])
      elsif line =~ /ClamAV-clamd\ result:\ /
        return $'
      else·
        return []·
      end

  end
end

Cheers,
Krekna
This topic is locked and can not be replied to.