class MicroMicro::Parsers::BasePropertyParser

Attributes

node[R]
property[R]

Public Class Methods

attribute_value_from(node, attributes_map) click to toggle source

@param node [Nokogiri::XML::Element] @param attributes_map [Hash{String => Array}] @return [Array]

# File lib/micro_micro/parsers/base_property_parser.rb, line 25
def self.attribute_value_from(node, attributes_map)
  attributes_map.map do |attribute, names|
    node[attribute] if names.include?(node.name) && node[attribute]
  end.compact.first
end
new(property) click to toggle source

@param property [MicroMicro::Property, MicroMicro::ImpliedProperty]

# File lib/micro_micro/parsers/base_property_parser.rb, line 5
def initialize(property)
  @property = property
  @node = property.node
end

Public Instance Methods

value() click to toggle source

@see microformats.org/wiki/microformats2-parsing#parsing_a_p-_property @see microformats.org/wiki/microformats2-parsing#parsing_an_e-_property

@return [String]

# File lib/micro_micro/parsers/base_property_parser.rb, line 14
def value
  @value ||= begin
    Document.text_content_from(node) do |context|
      context.css('img').each { |img| img.content = " #{img['alt'] || img['src']} " }
    end
  end
end