class SeaLife::CLI
Public Instance Methods
call()
click to toggle source
# File lib/sea_life/cli.rb, line 3 def call puts "------------------------------------------------------------" puts "" puts " _________ .____ .__ _____" puts " / _____/ ____ _____ | | |__|/ ____\\____" puts " \\_____ \\_/ __ \\\\__ \\ | | | \\ __\\/ __ \\" puts " / \\ ___/ / __ \\| |___| || | \\ ___/" puts " /_________/\\____/ _____/ ________\\__||__| \\____/" puts "" puts "" puts "------------------------------------------------------------" puts "" puts "Welcome!" list_categories end
goodbye()
click to toggle source
# File lib/sea_life/cli.rb, line 143 def goodbye puts "------------------------------------------------------------" puts "" puts " _________ .____ .__ _____" puts " / _____/ ____ _____ | | |__|/ ____\\____" puts " \\_____ \\_/ __ \\\\__ \\ | | | \\ __\\/ __ \\" puts " / \\ ___/ / __ \\| |___| || | \\ ___/" puts " /_________/\\____/ _____/ ________\\__||__| \\____/" puts " See you soon!" puts "" puts "------------------------------------------------------------" end
list_animals(category)
click to toggle source
# File lib/sea_life/cli.rb, line 42 def list_animals(category) puts "Loading animals..." puts "" make_animals_from_category(category) if category.animals.size == 0 puts "Please select the animal you'd like to learn about:" animals = [] category.animals.each_with_index do |animal, i| puts "#{i + 1}. #{animal.name}" animals << animal end puts "" category_menu(animals) end
list_categories()
click to toggle source
# File lib/sea_life/cli.rb, line 20 def list_categories puts "" puts "Please choose a category to learn about:" puts "" make_categories if SeaLife::Category.all.size == 0 categories = SeaLife::Category.all categories.each_with_index do |category, i| puts "#{i + 1}. #{category.name}" end puts "" main_menu(categories) end
make_animals_from_category(category)
click to toggle source
# File lib/sea_life/cli.rb, line 62 def make_animals_from_category(category) SeaLife::Scraper.scrape_animals(category) end
make_categories()
click to toggle source
# File lib/sea_life/cli.rb, line 36 def make_categories SeaLife::Scraper.scrape_categories.each do |category| SeaLife::Category.new(category) end end
show_animal(animal)
click to toggle source
# File lib/sea_life/cli.rb, line 66 def show_animal(animal) SeaLife::Scraper.scrape_animal_info(animal) unless animal.scientific_name puts "" puts "--------------------------------------------------------------" puts "#{animal.name} (#{animal.scientific_name})" puts "" puts "Distribution: #{animal.distribution}" puts "Ecosystem/Habitat: #{animal.habitat}" puts "Feeding Habits: #{animal.habits}" puts "Conservation Status: #{animal.status}" puts "Taxonomy: #{animal.taxonomy}" puts "--------------------------------------------------------------" puts "" puts "#{animal.short_desc}" puts "" puts "Enter \"MORE\" to continue reading about the #{animal.name}." puts "You may also enter \"BACK\", \"MENU\", or \"EXIT\"." animal_menu(animal) end