Class: GreatSchools::School
Overview
GreatSchools School
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#city ⇒ Object
Returns the value of attribute city.
-
#district ⇒ Object
Returns the value of attribute district.
-
#district_id ⇒ Object
Returns the value of attribute district_id.
-
#district_nces_id ⇒ Object
Returns the value of attribute district_nces_id.
-
#enrollment ⇒ Object
Returns the value of attribute enrollment.
-
#fax ⇒ Object
Returns the value of attribute fax.
-
#grade_range ⇒ Object
Returns the value of attribute grade_range.
-
#id ⇒ Object
Returns the value of attribute id.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nces_id ⇒ Object
Returns the value of attribute nces_id.
-
#overview_link ⇒ Object
Returns the value of attribute overview_link.
-
#parent_rating ⇒ Object
Returns the value of attribute parent_rating.
-
#parent_reviews ⇒ Object
Returns the value of attribute parent_reviews.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#ratings_link ⇒ Object
Returns the value of attribute ratings_link.
-
#reviews_link ⇒ Object
Returns the value of attribute reviews_link.
-
#state ⇒ Object
Returns the value of attribute state.
-
#type ⇒ Object
Returns the value of attribute type.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
-
.browse(state, city, options = {}) ⇒ Object
Returns a list of schools in a city.
-
.nearby(state, options = {}) ⇒ Object
Returns a list of schools closest to the center of a city, ZIP Code or address.
-
.profile(state, id) ⇒ Object
Returns profile data for a specific school.
-
.search(state, query, options = {}) ⇒ Object
Returns a list of schools based on a search string.
Instance Method Summary collapse
-
#census ⇒ Object
Returns census and profile data for the school.
-
#reviews(options = {}) ⇒ Object
Returns a list of the most recent reviews for the school.
-
#score ⇒ Object
Returns test and rank data for the school.
Methods inherited from Model
Constructor Details
This class inherits a constructor from GreatSchools::Model
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
5 6 7 |
# File 'lib/great_schools/school.rb', line 5 def address @address end |
#city ⇒ Object
Returns the value of attribute city.
5 6 7 |
# File 'lib/great_schools/school.rb', line 5 def city @city end |
#district ⇒ Object
Returns the value of attribute district.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def district @district end |
#district_id ⇒ Object
Returns the value of attribute district_id.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def district_id @district_id end |
#district_nces_id ⇒ Object
Returns the value of attribute district_nces_id.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def district_nces_id @district_nces_id end |
#enrollment ⇒ Object
Returns the value of attribute enrollment.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def enrollment @enrollment end |
#fax ⇒ Object
Returns the value of attribute fax.
5 6 7 |
# File 'lib/great_schools/school.rb', line 5 def fax @fax end |
#grade_range ⇒ Object
Returns the value of attribute grade_range.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def grade_range @grade_range end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def id @id end |
#latitude ⇒ Object
Returns the value of attribute latitude.
5 6 7 |
# File 'lib/great_schools/school.rb', line 5 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
5 6 7 |
# File 'lib/great_schools/school.rb', line 5 def longitude @longitude end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def name @name end |
#nces_id ⇒ Object
Returns the value of attribute nces_id.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def nces_id @nces_id end |
#overview_link ⇒ Object
Returns the value of attribute overview_link.
6 7 8 |
# File 'lib/great_schools/school.rb', line 6 def overview_link @overview_link end |
#parent_rating ⇒ Object
Returns the value of attribute parent_rating.
6 7 8 |
# File 'lib/great_schools/school.rb', line 6 def @parent_rating end |
#parent_reviews ⇒ Object
Returns the value of attribute parent_reviews.
6 7 8 |
# File 'lib/great_schools/school.rb', line 6 def parent_reviews @parent_reviews end |
#phone ⇒ Object
Returns the value of attribute phone.
5 6 7 |
# File 'lib/great_schools/school.rb', line 5 def phone @phone end |
#ratings_link ⇒ Object
Returns the value of attribute ratings_link.
6 7 8 |
# File 'lib/great_schools/school.rb', line 6 def @ratings_link end |
#reviews_link ⇒ Object
Returns the value of attribute reviews_link.
6 7 8 |
# File 'lib/great_schools/school.rb', line 6 def reviews_link @reviews_link end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/great_schools/school.rb', line 5 def state @state end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/great_schools/school.rb', line 4 def type @type end |
#website ⇒ Object
Returns the value of attribute website.
5 6 7 |
# File 'lib/great_schools/school.rb', line 5 def website @website end |
Class Method Details
.browse(state, city, options = {}) ⇒ Object
Returns a list of schools in a city.
Attributes
-
state
- Two letter state abbreviation -
city
- Name of city
Options
-
:school_types
- Type of school(s) you wish to appear in the list:'public', 'charter', and/or 'private'
-
:level
- Level of school you wish to appear in the list:'elementary-schools', 'middle-schools', or 'high-schools'
-
:sort
- How to sort the results, either by name (ascending),by GreatSchools rating (descending), or by overall parent rating (descending). The default sort is name (ascending). When sorted by rating, schools without a rating will appear last. Options: 'name', 'gs_rating', or 'parent_rating'
-
:limit
- Maximum number of schools to return. This defaultsto 200. To get all results, use -1.
– TODO: handle validations ++
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/great_schools/school.rb', line 37 def browse(state, city, = {}) school_types = Array.wrap(.delete(:school_types)).join('-') level = .delete(:level) url = "schools/#{state.upcase}/#{parameterize(city)}" url << "/#{school_types}" if school_types.present? url << "/#{level}" if level.present? response = GreatSchools::API.get(url, .slice(:sort, :limit)) Array.wrap(response).map { |school| new(school) } end |
.nearby(state, options = {}) ⇒ Object
Returns a list of schools closest to the center of a city, ZIP Code or address.
Attributes
-
state
- Two letter state abbreviation
Options
-
:zip_code
- 5 digit zip code -
:city
- Name of city -
:address
- Address of location -
:latitude
- Latitude of location -
:longitude
- Longitude of location -
:school_types
- Type of school(s) you wish to appear in the list:'public', 'charter', and/or 'private'
-
:level
- Level of school you wish to appear in the list:'elementary-schools', 'middle-schools', or 'high-schools'
-
:minimum_schools
- Minimum number of schools to return. When provided,if the initial query field yields fewer schools than this value, the radius will be increased in 5 mile increments to a maximum of 50 miles or until the result set has enough schools to meet this value. Maximum value is 200. This value must be less than the limit or else it is ignored.
-
:radius
- Miles radius to confine search to. This default to 5,with a maximum of 50.
-
:limit
- Maximum number of schools to return. This defaults to 200.
– TODO: handle validations ++
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/great_schools/school.rb', line 81 def nearby(state, = {}) [:lat] = .delete(:latitude) [:levelCode] = .delete(:level) [:lon] = .delete(:longitude) [:minimumSchools] = .delete(:minimum_schools) [:schoolType] = .delete(:school_types).try(:join, '-') [:state] = state [:zip] = .delete(:zip_code) .slice!(:address, :city, :lat, :levelCode, :limit, :lon, :minimumSchools, :radius, :schoolType, :state, :zip) response = GreatSchools::API.get('schools/nearby', ) Array.wrap(response).map { |school| new(school) } end |
.profile(state, id) ⇒ Object
Returns profile data for a specific school.
Attributes
-
state
- Two letter state abbreviation -
id
- Numeric id of a school. This GreatSchools ID is included inother listing requests like +GreatSchools::School#browse+ and +GreatSchools::School#nearby+
105 106 107 108 109 |
# File 'lib/great_schools/school.rb', line 105 def profile(state, id) response = GreatSchools::API.get("schools/#{state.upcase}/#{id}") new(response) end |
.search(state, query, options = {}) ⇒ Object
Returns a list of schools based on a search string.
Attributes
-
state
- Two letter state abbreviation -
query
- Search query string
Options
-
:level
- Level of school you wish to appear in the list:'elementary-schools', 'middle-schools', or 'high-schools'
-
:sort
- This call by default sorts the results by relevance. Youcan sort the results alphabetically by using 'alpha'.
-
:limit
- Maximum number of schools to return. This defaults to200 and must be at least 1.
– TODO: handle validations ++
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/great_schools/school.rb', line 129 def search(state, query, = {}) [:levelCode] = .delete(:level) [:q] = query [:state] = state .slice!(:state, :q, :levelCode, :sort, :limit) response = GreatSchools::API.get('search/schools', ) Array.wrap(response).map { |school| new(school) } end |
Instance Method Details
#census ⇒ Object
Returns census and profile data for the school.
142 143 144 |
# File 'lib/great_schools/school.rb', line 142 def census GreatSchools::Census.for_school(state, id) end |
#reviews(options = {}) ⇒ Object
Returns a list of the most recent reviews for the school.
Options
-
:limit
- Maximum number of reviews to return. This defaults to 5.
168 169 170 |
# File 'lib/great_schools/school.rb', line 168 def reviews( = {}) GreatSchools::Review.for_school(state, id, .slice(:limit)) end |
#score ⇒ Object
Returns test and rank data for the school.
173 174 175 |
# File 'lib/great_schools/school.rb', line 173 def score GreatSchools::Score.for_school(state, id) end |