class MicroMicro::Parsers::ImpliedNamePropertyParser
Constants
- HTML_ATTRIBUTES_MAP
Public Instance Methods
value()
click to toggle source
@see microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties
@return [String]
# File lib/micro_micro/parsers/implied_name_property_parser.rb, line 12 def value @value ||= attribute_value || text_content end
Private Instance Methods
attribute_value()
click to toggle source
@return [String, nil]
# File lib/micro_micro/parsers/implied_name_property_parser.rb, line 29 def attribute_value candidate_nodes.map { |node| self.class.attribute_value_from(node, HTML_ATTRIBUTES_MAP) }.compact.first end
candidate_nodes()
click to toggle source
@return [Nokogiri::XML::NodeSet]
# File lib/micro_micro/parsers/implied_name_property_parser.rb, line 19 def candidate_nodes @candidate_nodes ||= Nokogiri::XML::NodeSet.new(node.document, child_nodes.unshift(node)) end
child_nodes()
click to toggle source
@return [Array]
# File lib/micro_micro/parsers/implied_name_property_parser.rb, line 24 def child_nodes [node.at_css('> :only-child'), node.at_css('> :only-child > :only-child')].compact.reject { |child_node| Item.item_node?(child_node) } end
text_content()
click to toggle source
@return [String]
# File lib/micro_micro/parsers/implied_name_property_parser.rb, line 34 def text_content @text_content ||= Document.text_content_from(node) { |context| context.css('img').each { |img| img.content = img['alt'] } } end