Class: ProductSpy::Host::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/product_spy/host.rb

Instance Method Summary collapse

Constructor Details

#initialize(regexp, pk_keys) ⇒ Parser

Returns a new instance of Parser.



4
5
6
7
# File 'lib/product_spy/host.rb', line 4

def initialize(regexp, pk_keys)
  @regexp = regexp
  @pk_keys = pk_keys
end

Instance Method Details

#get_pk(url) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/product_spy/host.rb', line 9

def get_pk(url)
  if m = @regexp.match(url)
    return @pk_keys.map do |i|
      m[i]
    end
  else
    return nil
  end
end