Sha256: f8a5b8289588566e7c27b2f2f6e572a3936596b9de8774f7c4f9c59514cd9552

Contents?: true

Size: 576 Bytes

Versions: 1

Compression:

Stored size: 576 Bytes

Contents

require 'microformat'

class Microformat::Simple < String
  extend Microformat::Base

  class << self
    def find_first(doc)
      find_every(doc).first
    end

    def build_class(tags)
      @from.inject([]) do |array, (key, value)|
        tags.each_child do |tag|
          next unless tag.respond_to? :attributes
          array << new(tag.innerHTML) if tag.attributes[key.to_s] == value.to_s
        end
        array
      end
    end

    def from(options)
      @from ||= {}
      options.each do |tag, value|
        @from[tag] = value
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mofo-0.1 lib/microformat/simple.rb