Class: Applephile::City
- Inherits:
-
Object
- Object
- Applephile::City
- Defined in:
- lib/applephile/city.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#city_url ⇒ Object
Returns the value of attribute city_url.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#name ⇒ Object
Returns the value of attribute name.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #add_item(item) ⇒ Object
- #get_apple_prods_by_price(set_price) ⇒ Object
-
#initialize(city_attributes) ⇒ City
constructor
A new instance of City.
Constructor Details
#initialize(city_attributes) ⇒ City
Returns a new instance of City.
8 9 10 11 12 |
# File 'lib/applephile/city.rb', line 8 def initialize(city_attributes) city_attributes.each {|key, value| self.send(("#{key}="), value)} @items = [] @@all << self end |
Instance Attribute Details
#city_url ⇒ Object
Returns the value of attribute city_url.
3 4 5 |
# File 'lib/applephile/city.rb', line 3 def city_url @city_url end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
4 5 6 |
# File 'lib/applephile/city.rb', line 4 def items @items end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/applephile/city.rb', line 3 def name @name end |
#state ⇒ Object
Returns the value of attribute state.
3 4 5 |
# File 'lib/applephile/city.rb', line 3 def state @state end |
Instance Method Details
#add_item(item) ⇒ Object
14 15 16 17 18 |
# File 'lib/applephile/city.rb', line 14 def add_item(item) item.city = self @items << item item end |
#get_apple_prods_by_price(set_price) ⇒ Object
20 21 22 |
# File 'lib/applephile/city.rb', line 20 def get_apple_prods_by_price(set_price) @items.select { |item| item.price.to_i >= set_price.to_i } end |