votable-rbn 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/votable-rbn.rb +15 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f83a5d9e7e1ce03115380acf08aca3679fe2f603
4
+ data.tar.gz: 3cfb20b57e54d705f050e7255b2fa26cc4350219
5
+ SHA512:
6
+ metadata.gz: 1d31f4a33dcbc895cd36398f3ea80e7e5ad896cb95747ed9697393db3160305fdf55ba88a47541e414ec38090b4b4869c3c88ba8287dd08ac973d758b917cfc4
7
+ data.tar.gz: b9a549f38e9f69966f3a54b2aa0eeedb2be37816b909137388a6c6c9dbfc3a8c72f1a111128c99074546a76ca85556fdcf1e30e20a8f07bac1c4bc082c18b498
@@ -0,0 +1,15 @@
1
+ module VotableRbn
2
+ extend ActiveSupport::Concern
3
+
4
+ def total_votes
5
+ self.up_votes - self.down_votes
6
+ end
7
+
8
+ def up_votes
9
+ self.votes.where(vote: true).size
10
+ end
11
+
12
+ def down_votes
13
+ self.votes.where(vote: false).size
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: votable-rbn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Robin Dickson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Calculates the number of upvotes, downvotes and the total (subtracting
14
+ the downvotes from the upvotes)
15
+ email: robindickson@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/votable-rbn.rb
21
+ homepage: http://www.github.com/rbndickson/votable-rbn
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.8
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A voting gem
45
+ test_files: []