Class: FeedParser::HyFeedBuilder
- Inherits:
-
Object
- Object
- FeedParser::HyFeedBuilder
- Includes:
- LogUtils::Logging
- Defined in:
- lib/feedparser/builder/microformats.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build_author(hy) ⇒ Object
- #build_feed(h) ⇒ Object
- #build_item(hy) ⇒ Object
-
#initialize(hash) ⇒ HyFeedBuilder
constructor
A new instance of HyFeedBuilder.
- #to_feed ⇒ Object
Constructor Details
#initialize(hash) ⇒ HyFeedBuilder
Returns a new instance of HyFeedBuilder.
16 17 18 |
# File 'lib/feedparser/builder/microformats.rb', line 16 def initialize( hash ) @feed = build_feed( hash ) end |
Class Method Details
.build(hash) ⇒ Object
11 12 13 14 |
# File 'lib/feedparser/builder/microformats.rb', line 11 def self.build( hash ) feed = self.new( hash ) feed.to_feed end |
Instance Method Details
#build_author(hy) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/feedparser/builder/microformats.rb', line 54 def ( hy ) = Author.new .name = hy.name ## todo - add: ## author.url end |
#build_feed(h) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# 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..each do || item. << ( ) end item end |
#to_feed ⇒ Object
20 21 22 |
# File 'lib/feedparser/builder/microformats.rb', line 20 def to_feed @feed end |