-
Notifications
You must be signed in to change notification settings - Fork 217
/
words.rb
36 lines (28 loc) · 824 Bytes
/
words.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module ActsAsVotable::Helpers
# this helper provides methods that help find what words are
# up votes and what words are down votes
#
# It can be called
#
# votable_object.votable_words.that_mean_true
#
module Words
def votable_words
VotableWords
end
end
class VotableWords
def self.that_mean_true
['up', 'upvote', 'like', 'liked', 'positive', 'yes', 'good', 'true', 1, true]
end
def self.that_mean_false
['down', 'downvote', 'dislike', 'disliked', 'negative', 'no', 'bad', 'false', 0, false]
end
# check is word is a true or bad vote
# if the word is unknown, then it counts it as a true/good
# vote. this exists to allow all voting to be good by default
def self.meaning_of word
!that_mean_false.include?(word)
end
end
end