class Descartes::Hackernews
Public Instance Methods
execute(m, url)
click to toggle source
# File lib/descartes/modules/hackernews.rb, line 23 def execute(m, url) begin page = Nokogiri::HTML open(url).read, nil, 'utf-8' title = page.at_xpath('//td[@class="title"]/a').text.to_s info = page.at_xpath('//td[@class="subtext"]').text.to_s.strip comments = info.match(/[0-9]+.comments/).to_s info = info.gsub(/\|.*/, "").rstrip m.reply "[HN] #{title} | #{info} | #{comments}" rescue; end end