Module: ActsAsStarrable::Starrable::LocalInstanceMethods

Defined in:
lib/acts_as_starrable/starrable.rb

Instance Method Summary collapse

Instance Method Details

#average_ratingObject



26
27
28
29
30
# File 'lib/acts_as_starrable/starrable.rb', line 26

def average_rating
  if avg = ratings.average('rating')
    (avg * 2).round / 2.0 # round to nearest .5 or .0
  end
end

#max_ratingObject



32
33
34
# File 'lib/acts_as_starrable/starrable.rb', line 32

def max_rating
  5
end

#starrable?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/acts_as_starrable/starrable.rb', line 22

def starrable?
  true
end