I am stuck trying to get my scrapped info into my cli class for a basic cli project. I added my scrapper class and the cli class code.
I am trying to display the scrapped information when the program is run. The user will pick a number and get a description for the stretch.
require "nokogiri"
require "open-uri"
class YogaCli::Scrapper
@@stretches = []
def self.scrape
@yoga_doc = Nokogiri::HTML(open("https://www.prevention.com/fitness/workouts/g30417941/best-yoga-stretches/"))
end
def self.scrape_stretch
self.scrape.each do |info|
name = info.search(".listicle-slide-hed-text")
description = info.search(".listicle-slide-dek")
Stretch.new(name,description)
end
end
end
The code is running but I am not sure how to print the info to the user
class YogaCli::CLI
def call
system("clear")
YogaCli::Scrapper.scrape_stretch
#first thing the user will see
greeting
display_stetch
while menu != "exit"
end
end
def greeting
puts "Hello pick a number"
end
def display_stretch
Stretch.all.each.with_index(1) do |stretch, i|
puts "#{i}. #{stretch.name}"
end
def display_info
Stretch.all.each.with_index(1) do |stretch, i|
end
end
end