Sha256: ce2dfebc539823bb4070c82a5854e1de787ffc0b9effeaff067087a3342425b8

Contents?: true

Size: 539 Bytes

Versions: 4

Compression:

Stored size: 539 Bytes

Contents

module Microformats2
  module Property
    CLASS_REG_EXP = /^(p-|u-|dt-|e-)/
    PREFIX_CLASS_MAP = {
      "p" => Text,
      "u" => Url,
      "dt" => DateTime,
      "e" => Embedded }

    class << self
	    def new(element, property_class, value=nil)
	      # p-class-name -> p
	      prefix = property_class.split("-").first
	      # find ruby class for kind of property
	      klass = PREFIX_CLASS_MAP[prefix]
	      raise InvalidPropertyPrefix unless klass
	      klass.new(element, property_class, value)
	    end
	  end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
microformats2-2.0.0.pre5 lib/microformats2/property.rb
microformats2-2.0.0.pre4 lib/microformats2/property.rb
microformats2-2.0.0.pre3 lib/microformats2/property.rb
microformats2-2.0.0.pre2 lib/microformats2/property.rb