Sha256: 832fca870e6a403718f439f6b3f9e3643eea1167c1c2595068300852401c64a5

Contents?: true

Size: 687 Bytes

Versions: 14

Compression:

Stored size: 687 Bytes

Contents

module Wombat
  module Processing
    module NodeSelector
      def select_nodes(selector, namespaces = nil)
        return [selector.to_s] if selector.is_a? Symbol

        if selector.is_a? String
          return @context.xpath selector[6..-1], namespaces if selector.start_with? "xpath="
          return @context.css selector[4..-1] if selector.start_with? "css="
        end

        if selector.is_a? Hash
          method = selector.flatten.first
          selector = selector.flatten.last
          return @context.xpath selector, namespaces if method == :xpath
          return @context.css selector if method == :css
        end

        [selector]
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wombat-3.0.0 lib/wombat/processing/node_selector.rb
wombat-2.10.0 lib/wombat/processing/node_selector.rb
wombat-2.9.0 lib/wombat/processing/node_selector.rb
wombat-2.8.0 lib/wombat/processing/node_selector.rb
wombat-2.7.0 lib/wombat/processing/node_selector.rb
wombat-2.6.0 lib/wombat/processing/node_selector.rb
wombat-2.5.1 lib/wombat/processing/node_selector.rb
wombat-2.5.0 lib/wombat/processing/node_selector.rb
wombat-2.4.0 lib/wombat/processing/node_selector.rb
wombat-2.3.0 lib/wombat/processing/node_selector.rb
wombat-2.2.1 lib/wombat/processing/node_selector.rb
wombat-2.2.0 lib/wombat/processing/node_selector.rb
wombat-2.1.3 lib/wombat/processing/node_selector.rb
wombat-2.1.2 lib/wombat/processing/node_selector.rb