Class: PricePulse::AmazonParser

Inherits:
Object
  • Object
show all
Defined in:
lib/price_pulse/amazon_parser.rb

Constant Summary collapse

AMAZON_URL =

Placeholder for the actual Amazon search URL

"https://www.amazon.com/s?k="

Class Method Summary collapse

Class Method Details

.get_price(html_content) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/price_pulse/amazon_parser.rb', line 8

def self.get_price(html_content)
  # In a real scenario, this method would use Nokogiri to parse the complex HTML.
  # For our simulated test, we return a fixed price based on the item name.
  if html_content.include?("Coffee")
    return 165.50
  elsif html_content.include?("Headphones")
    return 75.99
  else
    return nil
  end
end

.get_url(item_name) ⇒ Object



20
21
22
23
24
# File 'lib/price_pulse/amazon_parser.rb', line 20

def self.get_url(item_name)
  # Creates a search URL for Amazon by replacing spaces with '+'
  search_term = item_name.gsub(' ', '+')
  "#{AMAZON_URL}#{search_term}"
end