Class: SnesFinderCliApp::Target
- Inherits:
-
Object
- Object
- SnesFinderCliApp::Target
- Defined in:
- lib/snes_finder_cli_app/snes_finder.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#more_info ⇒ Object
Returns the value of attribute more_info.
-
#status ⇒ Object
Returns the value of attribute status.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize ⇒ Target
constructor
A new instance of Target.
- #scraper ⇒ Object
Constructor Details
#initialize ⇒ Target
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
#doc ⇒ Object
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_info ⇒ Object
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 |
#status ⇒ Object
Returns the value of attribute status.
49 50 51 |
# File 'lib/snes_finder_cli_app/snes_finder.rb', line 49 def status @status end |
#url ⇒ Object
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
#scraper ⇒ Object
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 |