class Object
Public Instance Methods
get_namaste()
click to toggle source
# File lib/namaste.rb, line 18 def get_namaste html = Nokogiri::HTML(open('http://stayoutofmynamastespace.com/random')) quote = html.css("blockquote").text.strip.capitalize citation = html.xpath("//html/body/section/section/div/article/div/section/div").text.strip.capitalize res = quote + " - " + citation # Tries again to get new quote if previous attempts returned invalid responses. if quote.empty? || quote.nil? || res.to_s.length > 300 || citation.empty? || citation.nil? res = get_namaste() else return res end end