Class: Applephile::City

Inherits:
Object
  • Object
show all
Defined in:
lib/applephile/city.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Instance Method Summary collapse

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_urlObject

Returns the value of attribute city_url.



3
4
5
# File 'lib/applephile/city.rb', line 3

def city_url
  @city_url
end

#itemsObject (readonly)

Returns the value of attribute items.



4
5
6
# File 'lib/applephile/city.rb', line 4

def items
  @items
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/applephile/city.rb', line 3

def name
  @name
end

#stateObject

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