Sha256: daffb3b48a00e38c9d953b519de6223a66e34056e3f53a323b02641e5faabccd

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

module HentryConsumer
  class HFeed
    attr_accessor :html, :entries

    def initialize(html)
      @html = Nokogiri::HTML(open(html).read)
      @entries = []
      parse_html
    end

    def parse_html
      self.html.css(".h-entry").each do |hentry|
        entry = HEntry.new(hentry.children)
        self.entries << entry
      end
    end

    def to_html
      self.html.css(".h-entry").collect(&:to_html).join
    end
    alias_method :to_s, :to_html

    def to_hash
      {:items =>
        [{
          :type => ["h-feed"],
          :properties => {
            :entries => self.entries
          }
        }]
      }
    end

    def to_json(*a)
      to_hash.to_json(a)
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hentry_consumer-0.6.0 lib/hentry_consumer/h_feed.rb
hentry_consumer-0.5.3 lib/hentry_consumer/h_feed.rb
hentry_consumer-0.5.2 lib/hentry_consumer/h_feed.rb