Class: Grubber::Presenter
- Inherits:
-
Object
- Object
- Grubber::Presenter
- Defined in:
- lib/grubber/presenter.rb
Instance Attribute Summary collapse
-
#restaurants ⇒ Object
Returns the value of attribute restaurants.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(restaurants) ⇒ Presenter
constructor
A new instance of Presenter.
- #present ⇒ Object
- #stars(rating) ⇒ Object
Constructor Details
#initialize(restaurants) ⇒ Presenter
Returns a new instance of Presenter.
9 10 11 |
# File 'lib/grubber/presenter.rb', line 9 def initialize(restaurants) @restaurants = [*restaurants] end |
Instance Attribute Details
#restaurants ⇒ Object
Returns the value of attribute restaurants.
7 8 9 |
# File 'lib/grubber/presenter.rb', line 7 def restaurants @restaurants end |
Instance Method Details
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/grubber/presenter.rb', line 29 def empty? self.restaurants.empty? end |
#present ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/grubber/presenter.rb', line 13 def present return nil if empty? restaurants.each do |r| puts "\n#{r.name} #{stars(r.)}" puts r.address puts "[#{r.category}] #{r.phone}" puts r.url end nil end |
#stars(rating) ⇒ Object
25 26 27 |
# File 'lib/grubber/presenter.rb', line 25 def stars() (" ★" * ) + (" ☆" * (5 - )) end |