Sha256: 0eb5a2809a007d2ac4196330287742adec97ba1d8e13e454936ff182a2cdcd11

Contents?: true

Size: 1007 Bytes

Versions: 245

Compression:

Stored size: 1007 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
      ###
      # look for node with +name+.  See Nokogiri.Slop
      def method_missing name, *args, &block
        prefix = implied_xpath_context

        if args.empty?
          list = xpath("#{prefix}#{name.to_s.sub(/^_/, '')}")
        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("#{prefix}#{name}[#{conds}]")
          end
        else
          CSS::Parser.without_cache do
            list = xpath(
              *CSS.xpath_for("#{name}#{args.first}", :prefix => prefix)
            )
          end
        end

        super if list.empty?
        list.length == 1 ? list.first : list
      end
    end
  end
end

Version data entries

245 entries across 245 versions & 21 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.3.1-x64-mingw32/lib/nokogiri/decorators/slop.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/nokogiri-1.6.3.1-x64-mingw32/lib/nokogiri/decorators/slop.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/nokogiri-1.6.3.1-x86-mingw32/lib/nokogiri/decorators/slop.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/nokogiri-1.6.3.1/lib/nokogiri/decorators/slop.rb
nokogiri-1.6.4.1 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.4.1-x86-mingw32 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.4.1-x64-mingw32 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.4.1-java lib/nokogiri/decorators/slop.rb
nokogiri-1.6.4 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.4-x86-mingw32 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.4-x64-mingw32 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.4-java lib/nokogiri/decorators/slop.rb
nokogiri-1.6.3.1 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.3.1-x86-mingw32 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.3.1-x64-mingw32 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.3.1-java lib/nokogiri/decorators/slop.rb
nokogiri-1.6.3 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.3-x86-mingw32 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.3-x64-mingw32 lib/nokogiri/decorators/slop.rb
nokogiri-1.6.3-java lib/nokogiri/decorators/slop.rb