Module: Wikifacts
- Defined in:
- lib/wikifacts.rb
Constant Summary collapse
- MIN_LEN =
60
- MAX_LEN =
120
Class Method Summary collapse
Class Method Details
.get_random_fact ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/wikifacts.rb', line 17 def Wikifacts.get_random_fact intro = "" until intro.length.between?(60,120) and intro.include?("est") intro = get_random_intro end return intro.capitalize rescue retry end |
.get_random_intro ⇒ Object
12 13 14 15 |
# File 'lib/wikifacts.rb', line 12 def Wikifacts.get_random_intro page = Nokogiri::HTML(open("http://fr.m.wikipedia.org/wiki/Sp%C3%A9cial:Page_au_hasard")) page.css("p").first.text.split("\n").first end |