Module: VoteGemTest

Extended by:
ActiveSupport::Concern
Defined in:
lib/vote_gem_test.rb,
lib/vote_gem_test/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#down_votesObject



19
20
21
# File 'lib/vote_gem_test.rb', line 19

def down_votes
  self.votes.where(vote: false).size
end

#total_votesObject



11
12
13
# File 'lib/vote_gem_test.rb', line 11

def total_votes
  up_votes - down_votes
end

#up_votesObject



15
16
17
# File 'lib/vote_gem_test.rb', line 15

def up_votes
  self.votes.where(vote: true).size
end