Class: HallidayWineList::Wine
- Inherits:
-
Object
- Object
- HallidayWineList::Wine
- Defined in:
- lib/halliday_wine_list/wine.rb
Constant Summary collapse
- @@all_wines =
[]
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#variety ⇒ Object
readonly
Returns the value of attribute variety.
-
#winery ⇒ Object
readonly
Returns the value of attribute winery.
Class Method Summary collapse
- .all_wines ⇒ Object
- .new_from_scraper(winery, variety, location, category) ⇒ Object
- .print_wines ⇒ Object
Instance Method Summary collapse
-
#initialize(winery = nil, variety = nil, location = nil, category) ⇒ Wine
constructor
A new instance of Wine.
Constructor Details
#initialize(winery = nil, variety = nil, location = nil, category) ⇒ Wine
Returns a new instance of Wine.
16 17 18 19 20 21 22 23 |
# File 'lib/halliday_wine_list/wine.rb', line 16 def initialize(winery= nil, variety= nil, location= nil, category) @winery = winery @variety = variety @location = location @@all_wines << self self.category = category category.add_wine(self) end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/halliday_wine_list/wine.rb', line 3 def category @category end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
4 5 6 |
# File 'lib/halliday_wine_list/wine.rb', line 4 def location @location end |
#variety ⇒ Object (readonly)
Returns the value of attribute variety.
4 5 6 |
# File 'lib/halliday_wine_list/wine.rb', line 4 def variety @variety end |
#winery ⇒ Object (readonly)
Returns the value of attribute winery.
4 5 6 |
# File 'lib/halliday_wine_list/wine.rb', line 4 def winery @winery end |
Class Method Details
.all_wines ⇒ Object
8 9 10 |
# File 'lib/halliday_wine_list/wine.rb', line 8 def self.all_wines @@all_wines end |
.new_from_scraper(winery, variety, location, category) ⇒ Object
25 26 27 |
# File 'lib/halliday_wine_list/wine.rb', line 25 def self.new_from_scraper(winery, variety, location, category) self.new(winery, variety, location, category) end |
.print_wines ⇒ Object
12 13 14 |
# File 'lib/halliday_wine_list/wine.rb', line 12 def self.print_wines @@all_wines.each.with_index(1) {|w, i| puts "#{i} #{w.winery} - #{w.variety} - #{w.location}."} end |