Class: SurfReport::CLI

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

Instance Method Summary collapse

Instance Method Details

#callObject



8
9
10
11
12
13
# File 'lib/surf_report/cli.rb', line 8

def call
  make_days
  list_surf_reports
  menu
  later
end

#laterObject



58
59
60
# File 'lib/surf_report/cli.rb', line 58

def later
  puts "Later brah! Hope the waves are swell;)"
end

#list_surf_reportsObject



20
21
22
23
24
25
26
27
28
# File 'lib/surf_report/cli.rb', line 20

def list_surf_reports
  puts "\n"
  puts "******".colorize(:blue) + "3 Day Surf Report for Los Angeles".colorize(:black) + "******".colorize(:blue)
  puts "\n"
  @days = SurfReport::Report.all
  @days.each.with_index(1) do |day, i|
    puts "#{i}.".colorize(:magenta) + "#{day.date}".colorize(:black) + "- #{day.forecast.colorize(:blue)}"
  end
end

#make_daysObject



15
16
17
18
# File 'lib/surf_report/cli.rb', line 15

def make_days
  days_array = Scraper.scrape_index_page
  SurfReport::Report.create_from_collection(days_array)
end


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
# File 'lib/surf_report/cli.rb', line 30

def menu
  input = nil
  while input != "exit"
    puts "\n"
    puts "What number would you like to see a detailed report for? Oh yeah...you can type 'list' to see the days again or 'later' to get outta here!"
    input = gets.strip.downcase

    if input.to_i.between?(1, 3)
      the_day = @days[input.to_i - 1]
      puts "\n"
      puts "The date you chose is #{the_day.date}".colorize(:red)
      puts "Wave Height : ".colorize(:cyan) + "#{the_day.wave_size.colorize(:black)}"
      puts "Wave Description: ".colorize(:cyan) + "#{the_day.wave_description.colorize(:black)}"
      puts "Swell Direction: ".colorize(:cyan) + "#{the_day.swell_direction.colorize(:black)}"
      puts "Surfer Dude says: ".colorize(:cyan) + "#{the_day.surfer_dude_says.colorize(:black)}"

    elsif input == "list"
      list_surf_reports
    elsif input == "later"
      break
    else
      puts "\n"
      puts "Not sure what you're getting at man. Maybe you should slow down a little. Take a deep breath."
    end
  end

end