Class: HallidayWineList::Wine

Inherits:
Object
  • Object
show all
Defined in:
lib/halliday_wine_list/wine.rb

Constant Summary collapse

@@all_wines =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#categoryObject

Returns the value of attribute category.



3
4
5
# File 'lib/halliday_wine_list/wine.rb', line 3

def category
  @category
end

#locationObject (readonly)

Returns the value of attribute location.



4
5
6
# File 'lib/halliday_wine_list/wine.rb', line 4

def location
  @location
end

#varietyObject (readonly)

Returns the value of attribute variety.



4
5
6
# File 'lib/halliday_wine_list/wine.rb', line 4

def variety
  @variety
end

#wineryObject (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_winesObject



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


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