Class: MicroMicro::Parsers::ImpliedPhotoPropertyParser

Inherits:
BaseImpliedPropertyParser show all
Defined in:
lib/micro_micro/parsers/implied_photo_property_parser.rb

Constant Summary collapse

CSS_SELECTORS_ARRAY =
["> img[src]:only-of-type", "> object[data]:only-of-type"].freeze
HTML_ELEMENTS_MAP =
{
  "img"    => "src",
  "object" => "data"
}.freeze

Instance Method Summary collapse

Methods inherited from BasePropertyParser

#initialize

Constructor Details

This class inherits a constructor from MicroMicro::Parsers::BasePropertyParser

Instance Method Details

#valueString, ...

[View source]

19
20
21
22
23
24
25
26
27
28
# File 'lib/micro_micro/parsers/implied_photo_property_parser.rb', line 19

def value
  @value ||=
    if attribute_value
      if candidate_node.matches?("img[alt], img[srcset]")
        ImageElementParser.new(candidate_node, attribute_value).to_h
      else
        attribute_value
      end
    end
end