Sha256: 35c357ccfdd1a2fd5874ba12e4222e3a46f53ea0b46d87a53596117924bdab1e

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

module Microformats2
  module ImpliedProperty
    class Url < Foundation

      def method_name
        "url"
      end

      def to_s
        @to_s = absolutize(super.to_s) if super.to_s != ""
      end

      # TODO: make dry, repeated in Collection
      def absolutize(href)
        uri = URI.parse(href)

        if @base && !uri.absolute?
          uri = URI.join(@base, href)
        end

        uri.normalize!
        uri.to_s
      end

      protected

      def name_map
        { "a" => "href" }
      end

      def selector_map
        { ">a[href]:only-of-type" => "href" }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
microformats2-2.0.0 lib/microformats2/implied_property/url.rb