Class: BestCity::City

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rank_city = nil, population = nil, median_annual_salary = nil, quality_of_life = nil, overall_value = nil, description = nil) ⇒ City

Returns a new instance of City.



7
8
9
10
11
12
13
14
15
16
# File 'lib/best_cities/city.rb', line 7

def initialize(rank_city=nil, population=nil, median_annual_salary=nil, quality_of_life=nil, overall_value=nil,description=nil)
  @description = description
  @rank_city = rank_city
  @population=population
  @median_annual_salary=median_annual_salary
  @quality_of_life=quality_of_life
  @overall_value=overall_value
  @@all.unshift(self)

end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#median_annual_salaryObject

Returns the value of attribute median_annual_salary.



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

def median_annual_salary
  @median_annual_salary
end

#overall_valueObject

Returns the value of attribute overall_value.



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

def overall_value
  @overall_value
end

#populationObject

Returns the value of attribute population.



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

def population
  @population
end

#quality_of_lifeObject

Returns the value of attribute quality_of_life.



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

def quality_of_life
  @quality_of_life
end

#rank_cityObject

Returns the value of attribute rank_city.



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

def rank_city
  @rank_city
end

Class Method Details

.allObject



18
19
20
# File 'lib/best_cities/city.rb', line 18

def self.all
  @@all
end

.find(id) ⇒ Object



22
23
24
# File 'lib/best_cities/city.rb', line 22

def self.find(id)
  self.all[id-1]
end