Sha256: ebf6a94e9405cccf865591b87262d1b3e3c1257467ba559d5c1ddddc751d0223

Contents?: true

Size: 701 Bytes

Versions: 11

Compression:

Stored size: 701 Bytes

Contents

module Microformats2
  module ImpliedProperty
    class Name < Foundation

      def method_name
        "name"
      end

      def to_s
        @to_s ||= element_value || selector_value || text_value
      end

      protected

      def name_map
        { "img" => "alt",
          "abbr" => "title" }
      end

      def selector_map
        { ">img[alt]:only-of-type" => "alt",
          ">abbr[title]:only-of-type" => "title",
          ">:only-of-type>img[alt]:only-of-type" => "alt",
          ">:only-of-type>abbr[title]:only-of-type" => "title" }
      end

      private

      def text_value
        @element.inner_text.gsub(/\n+/, " ").gsub(/\s+/, " ").strip
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
microformats2-2.9.0 lib/microformats2/implied_property/name.rb
microformats2-2.1.0 lib/microformats2/implied_property/name.rb
microformats2-2.0.3 lib/microformats2/implied_property/name.rb
microformats2-2.0.2 lib/microformats2/implied_property/name.rb
microformats2-2.0.1 lib/microformats2/implied_property/name.rb
microformats2-2.0.0 lib/microformats2/implied_property/name.rb
microformats2-2.0.0.pre5 lib/microformats2/implied_property/name.rb
microformats2-2.0.0.pre4 lib/microformats2/implied_property/name.rb
microformats2-2.0.0.pre3 lib/microformats2/implied_property/name.rb
microformats2-2.0.0.pre2 lib/microformats2/implied_property/name.rb
microformats2-2.0.0.pre1 lib/microformats2/implied_property/name.rb