class Hogwarts::CLI

Public Instance Methods

atlas(atlas) click to toggle source
# File lib/cli.rb, line 82
def atlas(atlas)
    puts ""
    @@atlas.each.with_index(1) do |title, i|
      puts "#{i}. #{title.name}"
    end
    puts ""
    puts "Please select a map number for link to more info or type 'exit' to leave program."
    menu_atlas
end
create_atlas_array() click to toggle source
# File lib/cli.rb, line 21
def create_atlas_array
    atlas_array = Hogwarts::Atlas.scrape_atlas
    atlas_array.map do |n|
      Hogwarts::Atlas.new(n[:name], n[:url])
    end
end
create_books_array() click to toggle source
# File lib/cli.rb, line 14
def create_books_array
    textbooks_array = Hogwarts::Textbooks.scrape_textbooks
    textbooks_array.map do |book|
      Hogwarts::Textbooks.new(book[:name], book[:url])
    end
end
goodbye() click to toggle source
# File lib/cli.rb, line 118
def goodbye
  abort("----------Thanks for coming!----------")
end
menu() click to toggle source
menu_atlas() click to toggle source
menu_textbook() click to toggle source
start() click to toggle source
# File lib/cli.rb, line 3
def start
    puts ""
    puts "----------Welcome to the Hogwarts Library!----------"
    puts ""
    puts "1. TextBooks"
    puts "2. Atlas of Hogwarts"
    @@textbooks = create_books_array
    @@atlas = create_atlas_array
    menu
end
textbooks(books) click to toggle source
# File lib/cli.rb, line 47
def textbooks(books)
    puts ""
    @@textbooks.each.with_index(1) do |title, i|
      puts "#{i}. #{title.name}"
    end
    puts ""
    puts "Please select a book number for link to more info or type 'exit' to leave program."
    menu_textbook
end