lib/micro_micro/helpers.rb in micromicro-4.0.0 vs lib/micro_micro/helpers.rb in micromicro-5.0.0

- old
+ new

@@ -8,13 +8,13 @@ # @param node [Nokogiri::XML::Element] # @param attributes_map [Hash{String => Array}] # @return [String, nil] def self.attribute_value_from(node, attributes_map) - attributes_map.filter_map do |attribute, names| - node[attribute] if names.include?(node.name) && node[attribute] - end.first + attributes_map + .filter_map { |attribute, names| node[attribute] if names.include?(node.name) && node[attribute] } + .first end # @param node [Nokogiri::XML::Element] # @return [Boolean] def self.ignore_node?(node) @@ -52,11 +52,11 @@ end # @param node [Nokogiri::XML::Element] # @return [Array<String>] def self.root_class_names_from(node) - node.classes.grep(/^h(?:-[0-9a-z]+)?(?:-[a-z]+)+$/).uniq.sort + Set[*node.classes.grep(/^h(?:-[0-9a-z]+)?(?:-[a-z]+)+$/)].to_a.sort end # @see https://microformats.org/wiki/microformats2-parsing#parse_an_element_for_properties # microformats.org: microformats2 parsing specification § Parse an element for properties # @see https://microformats.org/wiki/microformats2-parsing#parsing_for_implied_properties @@ -77,18 +77,18 @@ # microformats.org: Value Class Pattern § Basic Parsing # # @param node [Nokogiri::XML::Element] # @return [Boolean] def self.value_class_node?(node) - node.classes.include?('value') + node.classes.include?("value") end # @see https://microformats.org/wiki/value-class-pattern#Parsing_value_from_a_title_attribute # microformats.org: Value Class Pattern § Parsing value from a title attribute # # @param node [Nokogiri::XML::Element] # @return [Boolean] def self.value_title_node?(node) - node.classes.include?('value-title') + node.classes.include?("value-title") end end end