Class: NjFishingReport::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/nj_fishing_report/cli.rb

Instance Method Summary collapse

Instance Method Details

#callObject



4
5
6
7
8
# File 'lib/nj_fishing_report/cli.rb', line 4

def call
  greeting
  create_fishing_location_and_report
  run_program_interface
end

#create_fishing_location_and_reportObject



61
62
63
64
# File 'lib/nj_fishing_report/cli.rb', line 61

def create_fishing_location_and_report
  NjFishingReport::Scraper.scrape_fishing_location
  NjFishingReport::Scraper.scrape_fishing_report
end

#fishing_reportObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/nj_fishing_report/cli.rb', line 79

def fishing_report
  puts " "
  puts "Please input a number, or enter 'exit' to return to the main menu."
  puts " "
  puts " "
  input = gets.strip.downcase
  puts " "
  puts " "
  loop do
    if input == "exit"
      break
    elsif input.to_i < 1 || input.to_i > NjFishingReport::Fishing_Location.all.length
      puts "That is not a valid entry. Please input a number between 1 and #{NjFishingReport::Fishing_Location.all.length}, or type 'exit'"
      puts " "
      puts " "
      input = gets.strip.downcase
    else
      puts "********************************"
      puts "Fishing Report for #{NjFishingReport::Fishing_Location.all[input.to_i-1].name}:"
      puts "********************************"
      puts " "
      puts NjFishingReport::Fishing_Report.all[input.to_i-1].report
      puts " "
      sleep(2)
      break
    end
  end
end

#goodbyeObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/nj_fishing_report/cli.rb', line 108

def goodbye
  puts "-----------------------------------------"
  puts " "
  puts " "
  puts "Happy Fishing!"
  puts " "
  puts "Give a man a fish, and you feed him for a day."
  puts "Teach a man to fish, and you feed him for a lifetime."
  puts "- Unidentified Wise Man"
  puts " "
  puts " "
  puts "-----------------------------------------"
  puts " "
  puts " "
end

#greetingObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/nj_fishing_report/cli.rb', line 10

def greeting
  puts " "
  puts " "
  puts "Welcome to the New Jersey Fishing Report CLI"
  puts " "
  puts " "
  puts "Loading...."
  puts " "
  puts " "
end

#list_fishing_locationsObject



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/nj_fishing_report/cli.rb', line 66

def list_fishing_locations
  puts "-----------------------------------------"
  puts " "
  puts " "
  puts "*Fishing Locations in NJ*"
  puts " "
  puts " "
  NjFishingReport::Fishing_Location.all.each_with_index do |location, index|
    puts "#{index + 1}. #{location.name}"
    puts " "
  end
end

#run_program_interfaceObject



21
22
23
24
25
26
27
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
54
55
56
57
58
59
# File 'lib/nj_fishing_report/cli.rb', line 21

def run_program_interface
  loop do
    puts "-----------------------------------------"
    puts " "
    puts "For a list of fishing spots, enter 'list'"
    puts " "
    puts "-----------------------------------------"
    puts " "
    puts "To quit, enter 'exit'"
    puts " "
    puts "-----------------------------------------"
    puts " "
    puts "What would you like to do?"
    puts " "
    puts " "
    input = gets.strip.downcase
    puts " "
    puts " "

    if input == 'exit'
      goodbye
      break
    elsif input == 'list'
      list_fishing_locations
      fishing_report
    else
      puts "+++++++++++++++++++++++++++"
      puts "+++++++++++++++++++++++++++"
      puts " "
      puts "Please type a valid entry"
      puts " "
      puts "+++++++++++++++++++++++++++"
      puts "+++++++++++++++++++++++++++"
      puts " "
      puts " "
      sleep(2)
    end
  end
end