Class: LocalRealEstate::CLI
- Inherits:
-
Object
- Object
- LocalRealEstate::CLI
- Defined in:
- lib/local_real_estate/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #detail_menu ⇒ Object
- #detailed_view(selection) ⇒ Object
- #goodbye ⇒ Object
- #greeting ⇒ Object
- #invalid_input ⇒ Object
- #menu ⇒ Object
- #new_search ⇒ Object
- #print_listings ⇒ Object
- #zip_method ⇒ Object
Instance Method Details
#call ⇒ Object
2 3 4 5 |
# File 'lib/local_real_estate/cli.rb', line 2 def call greeting end |
#detail_menu ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/local_real_estate/cli.rb', line 22 def 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' when 'new' when 'exit' goodbye else invalid_input end end |
#detailed_view(selection) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# 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 ⇒ Object
79 80 81 |
# File 'lib/local_real_estate/cli.rb', line 79 def goodbye puts 'See you next time!' end |
#greeting ⇒ Object
7 8 9 10 11 12 13 14 15 |
# 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 ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/local_real_estate/cli.rb', line 71 def invalid_input puts ' - - - - - - - - - - - - - ' puts 'Input not recognized, please try again:' puts ' - - - - - - - - - - - - - ' sleep 2 end |
#menu ⇒ Object
17 18 19 20 |
# File 'lib/local_real_estate/cli.rb', line 17 def new_search end |
#new_search ⇒ Object
40 41 42 43 44 |
# File 'lib/local_real_estate/cli.rb', line 40 def new_search LocalRealEstate::Listing.all.clear puts 'Please type in the Zip code in which you would like to search' zip_method end |
#print_listings ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/local_real_estate/cli.rb', line 63 def print_listings puts "--------Listings in #{LocalRealEstate::Listing.current_city}--------" LocalRealEstate::Listing.all.each_with_index do |listing, i| puts "#{i + 1}. #{listing.address} - #{listing.bedrooms} #{listing.price}" end puts '-------------------------------------------' end |
#zip_method ⇒ Object
59 60 61 |
# File 'lib/local_real_estate/cli.rb', line 59 def zip_method LocalRealEstate::Scraper.new(gets.strip).create_listings end |