class Apartments::CLI

Public Instance Methods

call() click to toggle source
# File lib/apartments/cli.rb, line 3
def call
  Apartments::Scraper.new.make_apartments
  puts "Welcome to the latest listing of NY area Apartments. Hit 'Enter' to continue"
  gets
  start
end
print_apartment(apartment) click to toggle source
print_apartments() click to toggle source
see_another?() click to toggle source
# File lib/apartments/cli.rb, line 28
def see_another?
  puts ""
  puts "Would you like to see another apartment? (Y/N)"
  input = gets.strip.upcase
  if input == "Y"
    start
  elsif input == "N"
    puts ""
    puts "Good luck in your apartment search. Have a nice day!"
    exit
  else
    puts ""
    puts "Not sure what you have in mind.."
    see_another?
  end
end
select_apartment() click to toggle source
# File lib/apartments/cli.rb, line 16
def select_apartment
  puts ""
  input = nil
  while input.nil? || !input.between?(1,Apartments::Apartment.count)
    puts "which apartment would you like to have more information about?"
    input = gets.strip.to_i
  end
  apartment = Apartments::Apartment.find(input.to_i)
  print_apartment(apartment)
end
start() click to toggle source
# File lib/apartments/cli.rb, line 10
def start
  print_apartments
  select_apartment
  see_another?
end