Class: GreatSchools::Review

Inherits:
Model
  • Object
show all
Defined in:
lib/great_schools/review.rb

Overview

GreatSchools Review

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Model

#initialize

Constructor Details

This class inherits a constructor from GreatSchools::Model

Instance Attribute Details

#commentsObject

Returns the value of attribute comments.



5
6
7
# File 'lib/great_schools/review.rb', line 5

def comments
  @comments
end

#posted_dateObject

Returns the value of attribute posted_date.



5
6
7
# File 'lib/great_schools/review.rb', line 5

def posted_date
  @posted_date
end

#ratingObject

Returns the value of attribute rating.



5
6
7
# File 'lib/great_schools/review.rb', line 5

def rating
  @rating
end

Returns the value of attribute review_link.



5
6
7
# File 'lib/great_schools/review.rb', line 5

def review_link
  @review_link
end

#school_addressObject

Returns the value of attribute school_address.



4
5
6
# File 'lib/great_schools/review.rb', line 4

def school_address
  @school_address
end

#school_nameObject

Returns the value of attribute school_name.



4
5
6
# File 'lib/great_schools/review.rb', line 4

def school_name
  @school_name
end

#submitterObject

Returns the value of attribute submitter.



5
6
7
# File 'lib/great_schools/review.rb', line 5

def submitter
  @submitter
end

Class Method Details

.for_city(state, city, options = {}) ⇒ Object

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

Attributes

  • state - Two letter state abbreviation

  • city - Name of 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.



20
21
22
23
24
25
26
# File 'lib/great_schools/review.rb', line 20

def for_city(state, city, options = {})
  options[:cutoffAge] = options.delete(:cutoff_age) # TODO: make helper method to camelCase or map query attributes

  response = GreatSchools::API.get("reviews/city/#{state.upcase}/#{parameterize(city)}", options.slice(:cutoffAge, :limit))

  Array.wrap(response).map { |review| new(review) }
end

.for_school(state, id, options = {}) ⇒ Object

Returns a list of the most recent reviews for a school.

Attributes

  • state - Two letter state abbreviation

  • id - Numeric id of a school. This GreatSchools ID is included in

    other listing requests like +GreatSchools::School#browse+
    and +GreatSchools::School#nearby+
    

Options

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



40
41
42
43
44
# File 'lib/great_schools/review.rb', line 40

def for_school(state, id, options = {})
  response = GreatSchools::API.get("reviews/school/#{state.upcase}/#{id}", options.slice(:limit))

  Array.wrap(response).map { |review| new(review) }
end