Class: CheeseBoard::CheeseType

Inherits:
Object
  • Object
show all
Defined in:
lib/cheese_board/cheesetype.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ CheeseType

Returns a new instance of CheeseType.



5
6
7
8
9
# File 'lib/cheese_board/cheesetype.rb', line 5

def initialize(name)
  @name=name
  @cheeses=[]
  save
end

Instance Attribute Details

#charObject

Returns the value of attribute char.



3
4
5
# File 'lib/cheese_board/cheesetype.rb', line 3

def char
  @char
end

#cheesesObject

Returns the value of attribute cheeses.



3
4
5
# File 'lib/cheese_board/cheesetype.rb', line 3

def cheeses
  @cheeses
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/cheese_board/cheesetype.rb', line 3

def name
  @name
end

Class Method Details

.allObject



11
12
13
14
15
# File 'lib/cheese_board/cheesetype.rb', line 11

def self.all
  CheeseBoard::Scraper.scrape_cheese_types if @@all.empty?
  @@all
  
end

Instance Method Details

#countObject



25
26
27
# File 'lib/cheese_board/cheesetype.rb', line 25

def count
  @cheese.length
end

#get_cheesesObject



17
18
19
# File 'lib/cheese_board/cheesetype.rb', line 17

def get_cheeses
  CheeseBoard::Scraper.scrape_cheeses(self) if @cheeses.empty?
end

#saveObject



21
22
23
# File 'lib/cheese_board/cheesetype.rb', line 21

def save
  @@all << self
end