class MicroMicro::Parsers::UrlPropertyParser

Constants

EXTENDED_HTML_ATTRIBUTES_MAP
HTML_ATTRIBUTES_MAP

Public Instance Methods

value() click to toggle source

@see microformats.org/wiki/microformats2-parsing#parsing_a_u-_property @see microformats.org/wiki/microformats2-parsing#parse_an_img_element_for_src_and_alt

@return [String, Hash{Symbol => String}]

# File lib/micro_micro/parsers/url_property_parser.rb, line 20
def value
  @value ||= begin
    return resolved_value unless node.matches?('img[alt]')

    {
      value: resolved_value,
      alt: node['alt'].strip
    }
  end
end

Private Instance Methods

attribute_value() click to toggle source

@return [String, nil]

# File lib/micro_micro/parsers/url_property_parser.rb, line 34
def attribute_value
  self.class.attribute_value_from(node, HTML_ATTRIBUTES_MAP)
end
extended_attribute_value() click to toggle source

@return [String, nil]

# File lib/micro_micro/parsers/url_property_parser.rb, line 39
def extended_attribute_value
  self.class.attribute_value_from(node, EXTENDED_HTML_ATTRIBUTES_MAP)
end
resolved_value() click to toggle source

@return [String]

# File lib/micro_micro/parsers/url_property_parser.rb, line 44
def resolved_value
  @resolved_value ||= Addressable::URI.join(node.document.url, unresolved_value.strip).to_s
end
unresolved_value() click to toggle source

@return [String]

# File lib/micro_micro/parsers/url_property_parser.rb, line 49
def unresolved_value
  attribute_value || value_class_pattern_value || extended_attribute_value || Document.text_content_from(node)
end
value_class_pattern_value() click to toggle source

@return [String, nil]

# File lib/micro_micro/parsers/url_property_parser.rb, line 54
def value_class_pattern_value
  ValueClassPatternParser.new(node).value
end