<commit_before>class SciencemagLatestNews::CLI

  def call
    SciencemagLatestNews::Story.scrape_latest_stories
    greeting
    list
    menu
  end

  def greeting
    puts "Welcome to ScienceMag Latest News!"
  end

  def list
    # need to list all the story headlines here
    # use each.with_index(1) on collection of all stories
    # like @stories = Story.all, @stories.each.with_index(1) blah blah
    @stories = SciencemagLatestNews::Story.latest_stories
    @stories.each.with_index(1) do |story, i|
      puts "#{i}. #{story.headline}"
    end
  end

  def menu
    input = nil

    while input != "exit"
      puts "Type the number of the story you'd like to read. You can also type 'list' to see the stories again or 'exit' to exit."
      input = gets.chomp

      # need to check that input is correct - more than 0 but less than
      # total num of stories
      # could use a find method here and pass in input, story = Story.find(i)
      # then puts story.headline, story.author | story.date, story.content
      case input
      when "1" then puts "Here's more info on bees."
      when "2" then puts "Here's more info on volcano stuff."
      when "list" then list
      else "I don't know what you want to do. Type 'list' or 'exit'."
      end
    end
  end

end
<commit_msg>implemented find method in cli.rb<commit_after>class SciencemagLatestNews::CLI

  def call
    SciencemagLatestNews::Story.scrape_latest_stories
    greeting
    list
    menu
  end

  def greeting
    puts "Welcome to ScienceMag Latest News!"
  end

  def list
    @stories = SciencemagLatestNews::Story.latest_stories
    @stories.each.with_index(1) do |story, i|
      puts "#{i}. #{story.headline}"
    end
  end

  def menu
    input = nil

    while input != "exit"
      puts "Type the number of the story you'd like to read. You can also type 'list' to see the stories again or 'exit' to exit."
      input = gets.chomp

      if input.to_i > 0 && input.to_i <= SciencemagLatestNews::Story.latest_stories.size
        story = SciencemagLatestNews::Story.find(input)
        puts "#{story.headline}"
        puts "#{story.author} | #{story.date}"
        puts "#{story.content}"
      elsif input == "list"
        list
      elsif input == "exit"
        exit
      else
        puts "Please choose one of the options listed."
      end
    end
  end

end

{'fraction_non_alphanumeric': 0.0876005078290309, 'fraction_numerical': 0.0033855268726195515, 'mean_word_length': 2.554887218045113, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4605422', 'n_tokens_mistral': 763, 'n_tokens_neox': 736, 'n_words': 267}