Class: SnesFinderCliApp::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/snes_finder_cli_app/snes_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTarget

Returns a new instance of Target.



51
52
53
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 51

def initialize
  @url = "https://www.target.com/p/nintendo-174-super-nes-classic-edition/-/A-52826093#lnk=sametab"
end

Instance Attribute Details

#docObject

Returns the value of attribute doc.



49
50
51
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 49

def doc
  @doc
end

#more_infoObject

Returns the value of attribute more_info.



49
50
51
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 49

def more_info
  @more_info
end

#statusObject

Returns the value of attribute status.



49
50
51
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 49

def status
  @status
end

#urlObject

Returns the value of attribute url.



49
50
51
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 49

def url
  @url
end

Instance Method Details

#scraperObject



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 55

def scraper
  browser = Watir::Browser.new :chrome, headless: true
  browser.goto @url

  @doc = Nokogiri::HTML.parse(browser.html)

  browser.close

  @more_info = @doc.css(".accordionCard").text.gsub(/\s{2,}/,"\n").capitalize

  @status = @doc.css("#AddToCartAreaId .add-to-cart-wrap .btn-primary").text.strip.capitalize
end