Sha256: 4e3c219e56f7171f7d6e72e32e3e7fdf22ffc26491643aee1304b41a1783514e
Contents?: true
Size: 1015 Bytes
Versions: 4
Compression:
Stored size: 1015 Bytes
Contents
module Danger # Prints markdown containing a random post from # [thecodinglove.com](http://thecodinglove.com) # # @example Prints markdown containing a random post # # the_coding_love.random # # @see valeriomazzeo/danger-the_coding_love # @tags thecodinglove.com, coding, love, random, gif # class DangerTheCodingLove < Plugin # Prints markdown containing a random post from thecodinglove.com # # @return [text, image_url] # def random require 'open-uri' require 'nokogiri' @doc = Nokogiri::HTML(open("http://thecodinglove.com/random")) @doc = @doc.at_xpath("//div[@id='post1']") text = @doc.at_xpath("//div/h3").text image_url = @doc.at_xpath("//div[@class='bodytype']/p/img/@src").to_s markdown("------\n#{text}\n--\n![alt text](#{image_url} \"thecodinglove.com\")") return text, image_url end def self.instance_name to_s.gsub("Danger", "").danger_underscore.split("/").last end end end
Version data entries
4 entries across 4 versions & 1 rubygems