Class: AustinCrime::CLI
- Inherits:
-
Object
- Object
- AustinCrime::CLI
- Defined in:
- lib/austin_crime/cli.rb
Overview
this is my controller
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #inputs ⇒ Object
- #menu ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
4 |
# File 'lib/austin_crime/cli.rb', line 4 def initialize; end |
Instance Method Details
#call ⇒ Object
6 7 8 9 10 11 |
# File 'lib/austin_crime/cli.rb', line 6 def call puts 'Welcome to Austin Crime Search!' inputs # cya end |
#inputs ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/austin_crime/cli.rb', line 13 def inputs # Select type of crime to view puts <<-DOC 1. DWI 2. HARASSMENT 3. CRUELTY TO ANIMALS 4. THEFT DOC # @crimes = AustinCrime::Crime.all # @crimes.each.with_index(1) do |crime, i| # puts "#{i}. #{crime.type} - #{crime.increp} - #{crime.date}" # end end |
#menu ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/austin_crime/cli.rb', line 28 def input = 'nil' while input != 'q' puts "\nPlease enter the number of the crime type for more information. Or enter 'list' to see your list of options." puts "You may also enter 'q' to Quit." input = gets.strip.downcase # if input.to_i > 0 && input.to_i < 5 # puts AustinCrime::Crime.all case input when '1' puts AustinCrime::Crime.dwi when '2' puts AustinCrime::Crime.harassment when '3' puts AustinCrime::Crime.cruelty when '4' puts AustinCrime::Crime.theft when 'q' puts 'Thanks for visiting. Come again for more reasons NOT TO MOVE TO AUSTIN!' when 'list' inputs else puts "Need some help? Type 'list' to see your options or 'q' to quit." end end end |