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 andcan be in the range 1-100.
-
:sort
- How to sort the results. Defaults to 'distance'. Otheroptions 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
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 daysago 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