class Cryptonewbie::CLI

Public Instance Methods

call() click to toggle source
# File lib/cryptonewbie/cli.rb, line 3
def call
  Cryptonewbie::Scraper.new.make_cryptos
  start
end
goodbye() click to toggle source
# File lib/cryptonewbie/cli.rb, line 83
def goodbye
  puts ""
  puts "PLEASE RETURN AT ANY TIME TO VIEW THE TOP 5 CRYPTOCURRENCIES!"
  puts ""
end
list() click to toggle source
# File lib/cryptonewbie/cli.rb, line 8
def list
  puts ""
  puts "************* Today's Crypto-Market *************"
  puts ""
  Cryptonewbie::Crypto.all.each.with_index(1) do |crypto, i|
    puts "                   #{i}. #{crypto.name}"
  end
  puts ""
end
print_crypto(crypto) click to toggle source
start() click to toggle source
# File lib/cryptonewbie/cli.rb, line 18
def start
  list
  input = nil
  while input != "exit"
    puts "Enter the (NAME) or (#) of the CryptoCurrency you'd like more info on!"
    puts ""
    puts "           Enter list to see the Top-5 again!"
    puts "                          OR"
    puts "           Enter exit to end the program."
    puts ""
    input = gets.strip

    if input == "list"
      list
    elsif input.to_i == 0
      if crypto = Cryptonewbie::Crypto.find_by_name(input)
        print_crypto(crypto)
        puts ""
        puts "Would you like to see another cryptocurrency? ENTER Y or N"
        input = gets.strip.downcase
        if input == "y"
          start
        else
          goodbye
          exit
        end
      end
    elsif input.to_i < 6
      if crypto = Cryptonewbie::Crypto.find(input.to_i)
        print_crypto(crypto)
        puts ""
        puts "Would you like to see another cryptocurrency? ENTER Y or N"
        input = gets.strip.downcase
        if input == "y"
          start
        else
          goodbye
          exit
        end
      end
    else
      list
    end
  end
  goodbye
end