Class: Controller
- Inherits:
-
Object
- Object
- Controller
- Defined in:
- lib/controller.rb
Instance Method Summary collapse
- #another_joke?(response) ⇒ Boolean
- #display_image ⇒ Object
- #get_choice ⇒ Object
- #get_image ⇒ Object
- #get_image_punch_line ⇒ Object
- #get_joke ⇒ Object
- #get_punch_line ⇒ Object
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
- #welcome_screen ⇒ Object
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
6 7 8 9 10 |
# File 'lib/controller.rb', line 6 def initialize @viewer = Viewer.new @model = Model.new welcome_screen end |
Instance Method Details
#another_joke?(response) ⇒ Boolean
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/controller.rb', line 57 def another_joke?(response) case response when 'yes' get_choice when 'y' get_choice else @viewer.good_bye end end |
#display_image ⇒ Object
45 46 47 48 49 |
# File 'lib/controller.rb', line 45 def display_image @viewer.display_image(@punch_line, @image_url) input = @viewer.see_another? another_joke?(input) end |
#get_choice ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/controller.rb', line 17 def get_choice input = @viewer.choice_screen case input when '1' get_joke when '2' get_image else puts "Come back when you are ready." end end |
#get_image ⇒ Object
35 36 37 38 |
# File 'lib/controller.rb', line 35 def get_image @image_url = @model.get_funny_image_from_reddit get_image_punch_line end |
#get_image_punch_line ⇒ Object
40 41 42 43 |
# File 'lib/controller.rb', line 40 def get_image_punch_line @punch_line = @model.get_image_punch_line display_image end |
#get_joke ⇒ Object
29 30 31 32 33 |
# File 'lib/controller.rb', line 29 def get_joke joke = @model.get_joke_from_reddit @viewer.display_joke(joke) get_punch_line end |
#get_punch_line ⇒ Object
51 52 53 54 55 |
# File 'lib/controller.rb', line 51 def get_punch_line punch_line = @model.get_punch_line_from_reddit input = @viewer.display_punch_line(punch_line) another_joke?(input) end |
#welcome_screen ⇒ Object
12 13 14 15 |
# File 'lib/controller.rb', line 12 def welcome_screen @viewer.welcome_screen get_choice end |