Sha256: 7867c8871faf050447d09783649a3f8b799067e39e332e25fcf735070c5554a4
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module MicroMicro module Parsers class BasePropertyParser # @param property [MicroMicro::Property, MicroMicro::ImpliedProperty] def initialize(property) @property = property @node = property.node end # @see http://microformats.org/wiki/microformats2-parsing#parsing_a_p-_property # @see http://microformats.org/wiki/microformats2-parsing#parsing_an_e-_property # # @return [String] 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 # @param node [Nokogiri::XML::Element] # @param attributes_map [Hash{String => Array}] # @return [Array] 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 private attr_reader :node, :property end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
micromicro-1.0.0 | lib/micro_micro/parsers/base_property_parser.rb |