Class: NewEugeneListingCli::CLI
- Inherits:
-
Object
- Object
- NewEugeneListingCli::CLI
- Defined in:
- lib/new_eugene_listing_cli/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 |
# File 'lib/new_eugene_listing_cli/cli.rb', line 3 def call NewEugeneListingCli::Scraper.new.build_properties display_listings close end |
#close ⇒ Object
42 43 44 |
# File 'lib/new_eugene_listing_cli/cli.rb', line 42 def close puts "Thank you for using. Hope to see you again soon!" end |
#display_listings ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/new_eugene_listing_cli/cli.rb', line 10 def display_listings puts "The following are property listings in Eugene that are less than 24 hours old:" @all = NewEugeneListingCli::Listing.all @all.each.with_index(1) do |listing, i| puts "#{i}. #{listing.address} -- #{listing.price} -- #{listing.bedrooms}bd -- #{listing.bathrooms}ba" puts " #{listing.url}" end end |
#menu ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/new_eugene_listing_cli/cli.rb', line 19 def input = nil while input != "exit" puts "Please enter the number of the property you would like to see more information about or 'listings' to see the listings again or 'exit':" input = gets.strip.downcase if input.to_i > 0 this_listing = @all[input.to_i - 1] puts "ADDRESS: #{this_listing.address}" puts "PRICE: #{this_listing.price}" puts "BEDROOM(S): #{this_listing.bedrooms}" puts "BATHROOM(S): #{this_listing.bathrooms}" puts "SQUARE FOOTAGE: #{this_listing.sq_feet}" puts "PROPERTY TYPE: #{this_listing.property_type}" puts "DESCRIPTION: #{this_listing.property_description}" elsif input == 'listings' display_listings else "I'm sorry, I don't understand. Please enter the number of the property you would like to see more information about:" end end end |