Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
345 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...