class FeedParser::HyFeedBuilder
Public Class Methods
build( hash )
click to toggle source
# File lib/feedparser/builder/microformats.rb, line 11 def self.build( hash ) feed = self.new( hash ) feed.to_feed end
new( hash )
click to toggle source
# File lib/feedparser/builder/microformats.rb, line 16 def initialize( hash ) @feed = build_feed( hash ) end
Public Instance Methods
build_feed( h )
click to toggle source
# File lib/feedparser/builder/microformats.rb, line 25 def build_feed( h ) b = HyBuilder.new( h ) ## convert hash to structs ## use first feed - more really possible? ## fix/todo: handle no feed too!!! hy = b.feeds[0] ## pp hy feed = Feed.new feed.format = 'html' ### todo: add ## - feed.title ## - feed.url ## - feed.feed_url ## - feed.summary ## - feed.authors ## etc. hy.entries.each do |entry| feed.items << build_item( entry ) end feed # return new feed end
build_item( hy )
click to toggle source
# File lib/feedparser/builder/microformats.rb, line 67 def build_item( hy ) item = Item.new # Item.new item.title = hy.name item.url = hy.url item.published_local = hy.published_local item.published = hy.published item.content_html = hy.content_html item.content_text = hy.content_text item.summary = hy.summary ## check: how to add an id - auto-generate - why? why not?? ## item.id = h['id'] hy.authors.each do |author| item.authors << build_author( author ) end item end
to_feed()
click to toggle source
# File lib/feedparser/builder/microformats.rb, line 20 def to_feed @feed end