votes.rb 310 Bytes
Newer Older
1
module Votes
2 3 4 5
  # Return the number of +1 comments (upvotes)
  def upvotes
    notes.select(&:upvote?).size
  end
Riyad Preukschas's avatar
Riyad Preukschas committed
6 7 8 9 10

  # Return the number of -1 comments (downvotes)
  def downvotes
    notes.select(&:downvote?).size
  end
Riyad Preukschas's avatar
Riyad Preukschas committed
11 12 13 14 15

  # Return the total number of votes
  def votes_count
    upvotes + downvotes
  end
16
end