Class: Spaceship::Tunes::AppRatings

Inherits:
TunesBase show all
Defined in:
spaceship/lib/spaceship/tunes/app_ratings.rb

Overview

Represents app ratings from App Store Connect

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

Instance Method Summary collapse

Methods inherited from TunesBase

client

Methods inherited from Base

attr_accessor, attr_mapping, attributes, #attributes, factory, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s

Constructor Details

This class inherits a constructor from Spaceship::Base

Instance Attribute Details

#applicationSpaceship::Tunes::Application

Returns A reference to the application this version is for.

Returns:



9
10
11
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 9

def application
  @application
end

#five_star_rating_countInteger

Returns total number of five star ratings recevied.

Returns:

  • (Integer)

    total number of five star ratings recevied



27
28
29
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 27

def five_star_rating_count
  @five_star_rating_count
end

#four_star_rating_countInteger

Returns total number of four star ratings recevied.

Returns:

  • (Integer)

    total number of four star ratings recevied



24
25
26
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 24

def four_star_rating_count
  @four_star_rating_count
end

#one_star_rating_countInteger

Returns total number of one star ratings recevied.

Returns:

  • (Integer)

    total number of one star ratings recevied



15
16
17
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 15

def one_star_rating_count
  @one_star_rating_count
end

#rating_countInteger

Returns total number of ratings recevied.

Returns:

  • (Integer)

    total number of ratings recevied



12
13
14
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 12

def rating_count
  @rating_count
end

#three_star_rating_countInteger

Returns total number of three star ratings recevied.

Returns:

  • (Integer)

    total number of three star ratings recevied



21
22
23
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 21

def three_star_rating_count
  @three_star_rating_count
end

#two_star_rating_countInteger

Returns total number of two star ratings recevied.

Returns:

  • (Integer)

    total number of two star ratings recevied



18
19
20
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 18

def two_star_rating_count
  @two_star_rating_count
end

Instance Method Details

#average_ratingFloat

Returns the average rating for this summary (rounded to 2 decimal places).

Returns:

  • (Float)

    the average rating for this summary (rounded to 2 decimal places)



40
41
42
43
44
45
46
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 40

def average_rating
  ((one_star_rating_count +
    (two_star_rating_count * 2) +
    (three_star_rating_count * 3) +
    (four_star_rating_count * 4) +
    (five_star_rating_count * 5)) / rating_count.to_f).round(2)
end

#reviews(store_front = '', version_id = '', upto_date = nil) ⇒ Array

Returns of Review Objects.

Returns:

  • (Array)

    of Review Objects



49
50
51
52
53
54
55
# File 'spaceship/lib/spaceship/tunes/app_ratings.rb', line 49

def reviews(store_front = '', version_id = '', upto_date = nil)
  raw_reviews = client.get_reviews(application.apple_id, application.platform, store_front, version_id, upto_date)
  raw_reviews.map do |review|
    review["value"]["application"] = self.application
    AppReview.factory(review["value"])
  end
end