Sha256: bb62a6c7f5c7c0871a701e82466372c3ad947b6739bb9742007a7b51002c3a25

Contents?: true

Size: 938 Bytes

Versions: 3

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

module MicroMicro
  module Parsers
    class BasePropertyParser
      # @param property [MicroMicro::Property, MicroMicro::ImpliedProperty]
      def initialize(property)
        @property = property
        @node = property.node
      end

      # @see https://microformats.org/wiki/microformats2-parsing#parsing_a_p-_property
      #   microformats.org: microformats2 parsing specification § Parsing a +p-+ property
      # @see https://microformats.org/wiki/microformats2-parsing#parsing_an_e-_property
      #   microformats.org: microformats2 parsing specification § Parsing an +e-+ property
      #
      # @return [String]
      def value
        @value ||=
          Helpers.text_content_from(node) do |context|
            context.css('img').each { |img| img.content = " #{img['alt'] || img['src']} " }
          end
      end

      private

      attr_reader :node, :property
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
micromicro-4.0.0 lib/micro_micro/parsers/base_property_parser.rb
micromicro-3.1.0 lib/micro_micro/parsers/base_property_parser.rb
micromicro-3.0.0 lib/micro_micro/parsers/base_property_parser.rb