Sha256: 127de746826447a04e8961acde95b03369cb786981daa44c6d213129a02929c2

Contents?: true

Size: 726 Bytes

Versions: 7

Compression:

Stored size: 726 Bytes

Contents

Gem.find_files("hentry_consumer/element.rb").each { |path| require path }

module HentryConsumer
  class HCard < Element
    attr_accessor :name, :email, :url
    alias_method :emails, :email
    alias_method :urls, :url

    def parse_p_name(element)
      assign_value :name, element.text
    end

    def parse_u_email(element)
      assign_value :email, element["href"]
    end

    def parse_u_url(element)
      assign_value :url, element["href"]
    end
    
    def to_hash
      {
        :type => ["h-card"],
        :properties => {
          :name  => self.name,
          :email => self.email,
          :url   => self.url
        }
      }
    end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hentry_consumer-0.8.3 lib/hentry_consumer/h_card.rb
hentry_consumer-0.8.2 lib/hentry_consumer/h_card.rb
hentry_consumer-0.8.1 lib/hentry_consumer/h_card.rb
hentry_consumer-0.8.0 lib/hentry_consumer/h_card.rb
hentry_consumer-0.7.0 lib/hentry_consumer/h_card.rb
hentry_consumer-0.6.0 lib/hentry_consumer/h_card.rb
hentry_consumer-0.5.3 lib/hentry_consumer/h_card.rb