lib/tr4n5l4te/translator.rb in tr4n5l4te-0.1.1 vs lib/tr4n5l4te/translator.rb in tr4n5l4te-0.1.2

- old
+ new

@@ -10,10 +10,12 @@ @sleep_time = args.fetch(:sleep_time, 2) @agent = Agent.new end def translate(text, from_lang, to_lang) - return '' if text.trim.empty? + return '' if text.nil? || text == '' + text.strip! + return '' if text == '' encoded_text = URI.encode(text) url = "#{START_PAGE}/##{from_lang}/#{to_lang}/#{encoded_text}" load_cookies agent.visit(url) store_cookies