Module: ExtraLoop::Utils::ScrapingHelpers

Defined in:
lib/extraloop/utils.rb

Instance Method Summary collapse

Instance Method Details

#values_for_param(param) ⇒ Object

Generates a proc that iterates over a list of anchors and collects the value of the specified paramenter



8
9
10
11
12
13
14
15
16
# File 'lib/extraloop/utils.rb', line 8

def values_for_param(param)
  lambda { |nodeList|
    nodeList.collect {|node|
      query = URI::parse(node.attr(:href)).query
      query.split("&").collect { |token| token.split("=") }.
        detect{ |chunks| chunks.first == param.to_s }.last
    }.uniq
  }
end