Class: CombineHashtags::Router
- Inherits:
-
Object
- Object
- CombineHashtags::Router
- Defined in:
- lib/combine_hashtags/cli/router.rb
Overview
Router for CLI
Instance Method Summary collapse
- #display_tasks ⇒ Object
-
#initialize(controller) ⇒ Router
constructor
A new instance of Router.
- #route_action(action) ⇒ Object
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(controller) ⇒ Router
Returns a new instance of Router.
5 6 7 8 |
# File 'lib/combine_hashtags/cli/router.rb', line 5 def initialize(controller) @controller = controller @running = true end |
Instance Method Details
#display_tasks ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/combine_hashtags/cli/router.rb', line 38 def display_tasks puts "" puts "What do you want to do next?" puts "1 - Fetch data for a new profile" puts "2 - See profile's most popular hashtags" puts "3 - Start a search" puts " ---" puts "0 - Stop and exit the program" end |
#route_action(action) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/combine_hashtags/cli/router.rb', line 22 def route_action(action) case action when 1 then @controller.setup when 2 then @controller.list when 3 then @controller.search when 0 then stop else puts "Please select an option" end end |
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/combine_hashtags/cli/router.rb', line 10 def run puts "Welcome!" puts "---" while @running display_tasks action = gets.chomp.to_i print `clear` route_action(action) end end |
#stop ⇒ Object
34 35 36 |
# File 'lib/combine_hashtags/cli/router.rb', line 34 def stop @running = false end |