Sha256: 6566509bb93b8e0c219397ff7e20dc1ce26a874a5ecb07e6843022c541f2d68e

Contents?: true

Size: 1.73 KB

Versions: 6

Compression:

Stored size: 1.73 KB

Contents

module GreatSchools # :nodoc:
  # = GreatSchools Review
  class Review < Model
    attr_accessor :school_name, :school_address
    attr_accessor :review_link, :rating, :submitter, :posted_date, :comments

    class << self # Class methods
      # 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.
      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

      # 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.
      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
great_schools-0.2.3 lib/great_schools/review.rb
great_schools-0.2.1 lib/great_schools/review.rb
great_schools-0.2.0 lib/great_schools/review.rb
great_schools-0.1.2 lib/great_schools/review.rb
great_schools-0.1.1 lib/great_schools/review.rb
great_schools-0.1.0 lib/great_schools/review.rb