Sha256: 2857e146fb582b2a1adb871d473148b727c8764aefcf9aac0c2eebbbe081a6ef
Contents?: true
Size: 876 Bytes
Versions: 15
Compression:
Stored size: 876 Bytes
Contents
module Nokogiri module Decorators ### # The Slop decorator implements method missing such that a methods may be # used instead of XPath or CSS. See Nokogiri.Slop module Slop def method_missing name, *args, &block if args.empty? list = xpath("./#{name}") elsif args.first.is_a? Hash hash = args.first if hash[:css] list = css("#{name}#{hash[:css]}") elsif hash[:xpath] conds = Array(hash[:xpath]).join(' and ') list = xpath("./#{name}[#{conds}]") end else CSS::Parser.without_cache do list = xpath( *CSS.xpath_for("#{name}#{args.first}", :prefix => "./") ) end end super if list.empty? list.length == 1 ? list.first : list end end end end
Version data entries
15 entries across 15 versions & 1 rubygems