Sha256: c5eafa4b84ff2ecffcfcd445cedcc95184b722636763b470f3e68247a97afed8

Contents?: true

Size: 755 Bytes

Versions: 2

Compression:

Stored size: 755 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
      # @see https://microformats.org/wiki/microformats2-parsing#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

2 entries across 2 versions & 1 rubygems

Version Path
micromicro-2.0.1 lib/micro_micro/parsers/base_property_parser.rb
micromicro-2.0.0 lib/micro_micro/parsers/base_property_parser.rb