Class: MaBreweries::BREWERY
- Inherits:
-
Object
- Object
- MaBreweries::BREWERY
- Defined in:
- lib/ma_breweries/brewery.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#brewery_type ⇒ Object
Returns the value of attribute brewery_type.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#state ⇒ Object
Returns the value of attribute state.
-
#street ⇒ Object
Returns the value of attribute street.
-
#website_url ⇒ Object
Returns the value of attribute website_url.
Class Method Summary collapse
- .all ⇒ Object
- .all_names ⇒ Object
- .find_by_brewery_type(brewery_type) ⇒ Object
-
.find_by_city(city) ⇒ Object
def self.find_by_street(street) self.all.select {|brewery| brewery.street.downcase == street.downcase} end.
- .find_by_name(name) ⇒ Object
Instance Method Summary collapse
- #brew_info ⇒ Object
-
#initialize(attributes) ⇒ BREWERY
constructor
A new instance of BREWERY.
Constructor Details
#initialize(attributes) ⇒ BREWERY
Returns a new instance of BREWERY.
6 7 8 9 10 11 12 13 |
# File 'lib/ma_breweries/brewery.rb', line 6 def initialize(attributes) attributes.each do |key, value| if self.respond_to?(key) self.send(("#{key}="), value) end end @@all << self end |
Instance Attribute Details
#brewery_type ⇒ Object
Returns the value of attribute brewery_type.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def brewery_type @brewery_type end |
#city ⇒ Object
Returns the value of attribute city.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def country @country end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def name @name end |
#phone ⇒ Object
Returns the value of attribute phone.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def phone @phone end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def postal_code @postal_code end |
#state ⇒ Object
Returns the value of attribute state.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def state @state end |
#street ⇒ Object
Returns the value of attribute street.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def street @street end |
#website_url ⇒ Object
Returns the value of attribute website_url.
3 4 5 |
# File 'lib/ma_breweries/brewery.rb', line 3 def website_url @website_url end |
Class Method Details
.all ⇒ Object
15 16 17 |
# File 'lib/ma_breweries/brewery.rb', line 15 def self.all @@all end |
.all_names ⇒ Object
19 20 21 22 23 |
# File 'lib/ma_breweries/brewery.rb', line 19 def self.all_names self.all.each_with_index do |brewery, i| puts "#{i+1}: #{brewery.name}" end end |
.find_by_brewery_type(brewery_type) ⇒ Object
30 31 32 |
# File 'lib/ma_breweries/brewery.rb', line 30 def self.find_by_brewery_type(brewery_type) self.all.select {|brewery| brewery.brewery_type.downcase == brewery_type.downcase} end |
.find_by_city(city) ⇒ Object
def self.find_by_street(street)
self.all.select {|brewery| brewery.street.downcase == street.downcase}
end
38 39 40 |
# File 'lib/ma_breweries/brewery.rb', line 38 def self.find_by_city(city) self.all.select {|brewery| brewery.city.downcase == city.downcase} end |
.find_by_name(name) ⇒ Object
25 26 27 28 |
# File 'lib/ma_breweries/brewery.rb', line 25 def self.find_by_name(name) self.all.detect {|brewery| brewery.name.downcase == name.downcase} end |
Instance Method Details
#brew_info ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/ma_breweries/brewery.rb', line 48 def brew_info puts "Brewery Name: #{self.name}" puts "Brewery Type: #{self.brewery_type}" puts "Adress: #{self.street} #{self.city} #{self.state}, #{self.postal_code} #{self.country}" puts "Phone Number: #{self.phone}" puts "Website: #{self.website_url}" end |