Class: DailyMenu::Restaurant
- Inherits:
-
Object
- Object
- DailyMenu::Restaurant
- Defined in:
- lib/daily_menu/restaurant.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, scraper, filter) ⇒ Restaurant
constructor
A new instance of Restaurant.
- #menu ⇒ Object
Constructor Details
#initialize(name, scraper, filter) ⇒ Restaurant
Returns a new instance of Restaurant.
5 6 7 |
# File 'lib/daily_menu/restaurant.rb', line 5 def initialize(name, scraper, filter) @name, @scraper, @filter = name, scraper, filter end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/daily_menu/restaurant.rb', line 3 def name @name end |
Class Method Details
.from_hash(hash) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/daily_menu/restaurant.rb', line 13 def self.from_hash(hash) scraper = create_instance_from('Scrapers', hash[:scraper]) filter = create_instance_from('Filters', hash[:filter]) new(hash[:name], scraper, filter) end |
Instance Method Details
#menu ⇒ Object
9 10 11 |
# File 'lib/daily_menu/restaurant.rb', line 9 def @scraper.entries.select { |entry| @filter.matches?(entry) }.sort_by(&:time).last end |