class LocalRealEstate::CLI

Public Instance Methods

call() click to toggle source
# File lib/local_real_estate/cli.rb, line 2
def call
  greeting
  menu
end
detail_menu() click to toggle source
# File lib/local_real_estate/cli.rb, line 22
def detail_menu
  print_listings
  puts 'To see more info on a listing, please select a number from the list above:'
  detailed_view(gets.strip)
  puts 'To go back to the previous list type "back". Or "new" to start a new search by zip. To quit, type "exit"'
  input = gets.strip.downcase
  case input
  when 'back'
    detail_menu
  when 'new'
    menu
  when 'exit'
    goodbye
  else 
    invalid_input
  end
end
detailed_view(selection) click to toggle source
# File lib/local_real_estate/cli.rb, line 46
def detailed_view(selection)
  home = LocalRealEstate::Listing.all[selection.to_i - 1]
  puts '-------------------------------------------'
  puts "Address: #{home.address}. #{home.city},#{home.state}."
  puts "Price: #{home.price}"
  puts "Bedrooms:#{home.bedrooms}"
  puts "Bathrooms: #{home.bathrooms}"
  unless home.sqft == '' then puts "Square Feet: #{home.sqft}" end
  unless home.lot_size == '' then puts "Lot Size #{home.lot_size}" end
  unless home.cars == '' then puts "Garage: #{home.cars}" end
  puts '-------------------------------------------'
end
goodbye() click to toggle source
# File lib/local_real_estate/cli.rb, line 79
def goodbye
  puts 'See you next time!'
end
greeting() click to toggle source
# File lib/local_real_estate/cli.rb, line 7
def greeting
  system 'clear'
  puts '-------------------------------------------'
  puts '-------------------------------------------'
  puts 'Welcome to the Local Real Estate Listing app'
  puts 'This will display local real estate listings by'
  puts 'zip code and allow you to see expanded details on each listing'
  puts ''
end
invalid_input() click to toggle source
# File lib/local_real_estate/cli.rb, line 71
def invalid_input
  puts ' -  -  -  -  -  -  -  -  -  -  -  -  - '
  puts 'Input not recognized, please try again:'
  puts ' -  -  -  -  -  -  -  -  -  -  -  -  - '
  sleep 2
  detail_menu
end
menu() click to toggle source
print_listings() click to toggle source
zip_method() click to toggle source
# File lib/local_real_estate/cli.rb, line 59
def zip_method
  LocalRealEstate::Scraper.new(gets.strip).create_listings
end