Sha256: ef7cda51826af0cf16bca3758dfe967a011d36e798731a8e12b3c3c3f8471485
Contents?: true
Size: 792 Bytes
Versions: 1
Compression:
Stored size: 792 Bytes
Contents
require File.join(File.dirname(__FILE__), '..', 'sapo.rb') require 'open-uri' require 'json' module SAPO module Blogs class Post attr_accessor :title, :link, :author, :created_at, :description, :blog end # FIXME: add sort and pagination options def self.search(query) output = open("http://services.sapo.pt/Blogs/JSON/Search?q=#{CGI.escape(query)}").read json = JSON.parse(output) return json["rss"]["channel"]["item"].map do |p| post = Post.new post.title = p["title"] post.link = p["link"] post.author = p["author"] post.created_at = p["sapo:created"] post.description= p["description"] post.blog = p["source"]["url"] post end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tpinto-sapo-rb-0.0.3 | lib/sapo/blogs.rb |