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

Version Path
nokogiri-1.1.1-java lib/nokogiri/decorators/slop.rb
nokogiri-1.1.1-x86-mswin32-60 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.0-java lib/nokogiri/decorators/slop.rb
nokogiri-1.1.1 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.0-x86-mswin32-60 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.0 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.1-java lib/nokogiri/decorators/slop.rb
nokogiri-1.2.2-x86-mswin32-60 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.1-x86-mswin32-60 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.1 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.2-java lib/nokogiri/decorators/slop.rb
nokogiri-1.2.2 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.3 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.3-x86-mswin32-60 lib/nokogiri/decorators/slop.rb
nokogiri-1.2.3-java lib/nokogiri/decorators/slop.rb