Sha256: 78ce6da263727b8e992e8267f6fc908a76a15a1b71650b10a537d78f6dde889b

Contents?: true

Size: 562 Bytes

Versions: 2

Compression:

Stored size: 562 Bytes

Contents

require 'microformat'

class Microformat
  class Simple < String
    extend Microformat::Base

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

      def find_occurances(doc)
        @from ? doc/from_as_xpath : super(doc)
      end

      def build_class(tag)
        new(tag.innerText) 
      end

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

      def from_as_xpath
        "[#{@from.to_a * "|"}]"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mofo-0.1.2 lib/microformat/simple.rb
mofo-0.1.1 lib/microformat/simple.rb