lib/aranha/parsers/html/base.rb in aranha-parsers-0.17.1 vs lib/aranha/parsers/html/base.rb in aranha-parsers-0.18.0

- old
+ new

@@ -17,9 +17,23 @@ def field(name, type, xpath) @fields ||= [] @fields << Field.new(name, type, xpath) end + # @param node [Nokogiri::XML::Node] + # @return [Aranha::Parsers::Html::Base] + def from_node(node) + from_string(node.to_html) + end + + # @param haystack [String] + # @param needle [String] + # @return [String] + def xpath_ends_with(haystack, needle) + "substring(#{haystack}, string-length(#{haystack}) - string-length(#{needle}) + 1) " \ + "= #{needle}" + end + Field = Struct.new(:name, :type, :xpath) end def nokogiri @nokogiri ||= Nokogiri::HTML(content, &:noblanks)