Sha256: aaf6351a20449f6d956fc5859936e737432f2dbe964f1755e6278c7a84a113ab

Contents?: true

Size: 577 Bytes

Versions: 3

Compression:

Stored size: 577 Bytes

Contents

module HentryConsumer
  class Element
    def initialize(microformat)
      parse_elements(microformat)
    end
    
    def parse_elements(microformat)
      FormatClass.each do |letter|
        microformat.css(">*[class*=#{letter}-]").each do |a|
          self[symbolize_class(a["class"])] = a.text.gsub('\n', " ").strip
        end
      end
    end

    def symbolize_class(klass)
      klass.to_s.downcase.split.first.gsub(/\w{1,2}-/, "").to_sym
    end

    def []=(key, value)
      self.send(key.to_s + "=", value) if self.respond_to?(key.to_s + "=")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hentry_consumer-0.1.2 lib/hentry_consumer/element.rb
hentry_consumer-0.1.1 lib/hentry_consumer/element.rb
hentry_consumer-0.1.0 lib/hentry_consumer/element.rb