Class: ImpactHubEvents::CLI

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

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
8
9
# File 'lib/impact_hub_events/cli.rb', line 3

def call
  puts "Upcoming events at Impact Hub Seattle:"
  scraper = ImpactHubEvents::Scraper.new("https://impacthubseattle.com/events/")
  scraper.create_events
  scraper.populate_events
  self.list_events
end

#list_detail(event) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/impact_hub_events/cli.rb', line 19

def list_detail(event)
  puts
  puts Paint["#{event.title}", :green]
  puts
  puts Paint["Date: #{event.date}", :blue, :bright]
  puts Paint["Time: #{event.time}", :blue, :bright]
  puts Paint["Location: #{event.location}", :blue, :bright]
  unless event.description.nil?
    puts
    puts Paint["#{event.description}", :magenta, :bold]
  end
  puts
  self.list_menu
end

#list_eventsObject



11
12
13
14
15
16
17
# File 'lib/impact_hub_events/cli.rb', line 11

def list_events
  ImpactHubEvents::Event.all.each_with_index do |event, index|
    puts Paint["#{index + 1}. #{event.title}", :green]
  end
  puts
  self.list_menu
end

#list_menuObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/impact_hub_events/cli.rb', line 34

def list_menu
  puts "Select an event for more info, \"list\" to view events, or \"exit!\" to quit."
  input = nil
  until input == "exit!"
    input = gets.chomp
    if input.to_i.between?(1, (ImpactHubEvents::Event.all.count + 1))
      self.list_detail(ImpactHubEvents::Event.all[input.to_i - 1])
    elsif input == "list"
      self.list_events
    elsif input == "exit!"
      exit
    else
      puts "I didn't quite get that..."
      self.list_menu
    end
  end
end