Class: AmazonPattern

Inherits:
Object
  • Object
show all
Defined in:
lib/patterns/amazon_pattern.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAmazonPattern

Returns a new instance of AmazonPattern.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/patterns/amazon_pattern.rb', line 3

def initialize
  @block = lambda do |m|
    m.match :shipping , /Shipping & Handling/, /\$(\d+\.\d+)/
    m.match :total_price, /Total for this Order/, /\$(\d+\.\d+)/

    m.match_until :items, /\*{10}/ do |m|
      m.match :name, /\d+/, /"(.*)"/
      m.match :price, /\$(\d+\.\d+)/
    end
  end
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



2
3
4
# File 'lib/patterns/amazon_pattern.rb', line 2

def block
  @block
end