Sha256: 3e8b995381c88753a5863cc7a434eef36abef2624aec1d898e79e0376d4917e9

Contents?: true

Size: 826 Bytes

Versions: 15

Compression:

Stored size: 826 Bytes

Contents

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

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
acts_as_votable-0.10.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.9.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.8.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.7.1 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.7.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.6.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.5.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.4.0 lib/acts_as_votable/helpers/words.rb
jy-acts_as_votable-0.3.1 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.3.1 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.3.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.2.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.1.3 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.1.2 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.1.1 lib/acts_as_votable/helpers/words.rb