class MostHauntedCli::CLI

Public Class Methods

new() click to toggle source
# File lib/most_haunted/cli.rb, line 3
def initialize
    MostHauntedCli::Scraper.scrape_america
    MostHauntedCli::Scraper.states
end

Public Instance Methods

america_descriptions() click to toggle source
# File lib/most_haunted/cli.rb, line 61
    def america_descriptions
        input = nil
        while input != "exit"
            puts "--" * 30
            puts  <<-DOC.gsub /^\s*/, ''

            * choose an index (1-10) for more information on a location
            * 'list' for the 10 Most Haunted Places in America
            * 'main menu'
            * 'exit'
            DOC
            input = gets.strip.downcase

            if input.to_i.between?(1, MostHauntedCli::America.all.size)
                puts ''
                puts "Location: #{MostHauntedCli::America.all[input.to_i].location}"
                puts ''
                MostHauntedCli::America.america_descriptions(MostHauntedCli::America.find_description_by_input(input))
            elsif input == "list"
                puts ''
                MostHauntedCli::America.list_location_names
            elsif input == "main menu"
                start
            elsif input == 'exit'
                goodbye
                exit
            else
                puts ''
                puts "** Please enter valid input **"
                america_descriptions
            end
        end
    end
call() click to toggle source
# File lib/most_haunted/cli.rb, line 8
def call
    puts "--" * 17
    puts "Search for Scary Places Near You!"
    puts "--" * 17
    start
    goodbye
end
goodbye() click to toggle source
# File lib/most_haunted/cli.rb, line 131
def goodbye
    puts ''
    puts "Scare ya later!"
    system "clear"
end
list_america() click to toggle source
# File lib/most_haunted/cli.rb, line 56
def list_america
    puts ''
    MostHauntedCli::America.list_location_names
end
list_states() click to toggle source
# File lib/most_haunted/cli.rb, line 95
def list_states
    MostHauntedCli::States.state_columns
end
start() click to toggle source
# File lib/most_haunted/cli.rb, line 16
    def start
        puts ''
        puts <<-DOC.gsub /^\s*/, ''

            1. Most Haunted Places in America
            2. Choose a State
        DOC

        input = nil
        puts ''
        while input != "exit"
            puts "--" * 17
            puts "Please enter '1', '2', or 'exit'"
            puts ""
            input = gets.strip.downcase

            case input
            when "1"
                puts "--" * 17
                puts "10 Most Haunted Places in America"
                puts "--" * 17
                puts ""
                sleep(2)
                list_america
                america_descriptions
            when "2"
                puts ""
                list_states
                state_options
            when "exit"
                goodbye
                exit
            else
                puts ''
                puts "** Please enter valid input **"
                start
            end
        end
    end
state_options() click to toggle source
# File lib/most_haunted/cli.rb, line 99
    def state_options
        input = nil
        while input != "exit"
        puts "--" * 30
            puts <<-DOC.gsub /^\s*/, ''

            * choose an index (1-52) to discover the state's most haunted locations!
            * 'list' for a list of states
            * 'main menu'
            * 'exit'

            DOC
            input= gets.strip.downcase

            if input.to_i.between?(1, MostHauntedCli::States.all.length)
                MostHauntedCli::States.open_state_info(input.to_i)
            elsif input == 'main menu'
                start
            elsif input == 'list'
                puts ''
                MostHauntedCli::States.state_columns
            elsif input == 'exit'
                goodbye
                exit
            else
                puts ''
                puts "** Please enter valid input **"
                state_options
            end
        end
    end