class GreatSchools::City

GreatSchools City

– TODO: add method to grab nearby schools using +GreatSchools::School#nearby+ with the city and state options. ++

Attributes

charter_schools[RW]
city[RW]
city=[RW]
elementary_schools[RW]
high_schools[RW]
middle_schools[RW]
name[RW]
private_schools[RW]
public_schools[RW]
rating[RW]
state[RW]
total_schools[RW]

Public Class Methods

nearby(state, city, options = {}) click to toggle source

Returns a list of cities near another city.

Attributes

  • state - Two letter state abbreviation

  • city - Name of city

Options

  • :radius - Radius in miles to confine search to. Defaults to 15 and

    can be in the range 1-100.
  • :sort - How to sort the results. Defaults to 'distance'. Other

    options are 'name' to sort by city name in alphabetical
    order, and 'rating' to sort by GreatSchool city rating,
    highest first.

– TODO: handle validations ++

# File lib/great_schools/city.rb, line 32
def nearby(state, city, options = {})
  options.slice!(:radius, :sort)

  response = GreatSchools::API.get("cities/nearby/#{state.upcase}/#{parameterize(city)}", options)

  Array.wrap(response).map { |city| new(city.merge(state: state)) }
end
overview(state, city) click to toggle source

Returns information about a city.

Attributes

  • state - Two letter state abbreviation

  • city - Name of city

# File lib/great_schools/city.rb, line 46
def overview(state, city)
  response = GreatSchools::API.get("cities/#{state.upcase}/#{parameterize(city)}")

  new(response.merge(state: state))
end

Public Instance Methods

districts() click to toggle source

Returns a list of districts in a city.

# File lib/great_schools/city.rb, line 57
def districts
  @districts ||= GreatSchools::District.browse(state, city)
end
reviews(options = {}) click to toggle source

Returns a list of the most recent reviews for any schools in a city.

Options

  • :cutoff_age - Reviews must have been published after this many days

    ago to be returned.
  • :limit - Maximum number of reviews to return. This defaults to 5.

# File lib/great_schools/city.rb, line 68
def reviews(options = {})
  GreatSchools::Review.for_city(state, name, options.slice(:cuttoff_age, :limit))
end