Sha256: ef49630a96f374aa4e8d84a76a43247514c28d3ec1f64d8948a38db5c6445858
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
module HentryConsumer class HEntry < Element attr_accessor :name, :categories, :author, :content, :bookmark, :published_at, :summary # Certainly there is a better way to do this. def initialize(microformat) @categories = {} super end def parse_elements(microformat) FormatClass.each do |letter| microformat.css(">*[class*=#{letter}-]").each do |attrs| attrs["class"].split.each do |klass| parse_element(attrs, klass) end end end end private def parse_element(microformat, klass) case klass when 'h-card' self.author = HCard.new(microformat) when 'p-category' self.categories[microformat.text.gsub('\n', " ").strip] = microformat["href"] when 'e-content' self.content = parse_content(microformat) when'dt-published' self.published_at = microformat["datetime"] when "u-uid" self.bookmark = microformat["href"] else self[symbolize_class(klass)] = microformat.text.gsub('\n', " ").strip end end def parse_content(microformat) microformat.inner_html end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hentry_consumer-0.1.2 | lib/hentry_consumer/h_entry.rb |
hentry_consumer-0.1.1 | lib/hentry_consumer/h_entry.rb |
hentry_consumer-0.1.0 | lib/hentry_consumer/h_entry.rb |