Gem.find_files("hentry_consumer/element.rb").each { |path| require path } module HentryConsumer class HEntry < Element attr_accessor :name, :categories, :author, :content, :bookmark, :published_at, :summary alias_method :authors, :author def parse_p_name(element) assign_value :name, element.text end def parse_p_author(element) assign_value :author, HCard.new(element.children) end def parse_p_category(element) self.categories ||= {} self.categories[element.text.gsub("\n", " ").strip] = element["href"] end def parse_e_content(element) assign_value :content, element.inner_html end def parse_dt_published(element) assign_value :published_at, element["datetime"] end def parse_u_uid(element) assign_value :bookmark, element["href"] end def parse_p_summary(element) assign_value :summary, element.text end def to_hash { :type => ["h-entry"], :properties => { :name => self.name, :categories => self.categories, :author => self.author, :content => self.content, :bookmark => self.bookmark, :published_at => self.published_at, :summary => self.summary } } end def to_json(*a) to_hash.to_json(a) end end end