lib/quorable.rb in quorable-0.1.1 vs lib/quorable.rb in quorable-0.1.2

- old
+ new

@@ -1,14 +1,18 @@ require 'open-uri' require 'nokogiri' require 'pry' -BASE_URL = 'http://www.quora.com' +module Quorable + BASE_URL = 'http://www.quora.com' -def parameterize(topic) - topic.split(' ').map(&:downcase).map(&:capitalize).join('-') -end + def feed(topic) + doc = Nokogiri::HTML.parse(open("#{BASE_URL}/#{parameterize(topic)}")) + paths = doc.css('.question_link').map { |link| link['href'] } + end -def feed(topic) - doc = Nokogiri::HTML.parse(open("#{BASE_URL}/#{parameterize(topic)}")) - paths = doc.css('.question_link').map { |link| link['href'] } + private + + def parameterize(topic) + topic.split(' ').map(&:downcase).map(&:capitalize).join('-') + end end \ No newline at end of file