Sha256: c39240f8a84f22108caf3e3e28ed7811ab8b1bc3feb3df2298446634831e0675

Contents?: true

Size: 872 Bytes

Versions: 8

Compression:

Stored size: 872 Bytes

Contents

# frozen_string_literal: true

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", "agree", "true", 1, true]
    end

    def self.that_mean_false
      ["down", "downvote", "dislike", "disliked", "negative", "no", "bad", "disagree", "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

8 entries across 8 versions & 1 rubygems

Version Path
acts_as_votable-0.14.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.13.2 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.13.1 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.13.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.12.1 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.12.0 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.11.1 lib/acts_as_votable/helpers/words.rb
acts_as_votable-0.11.0 lib/acts_as_votable/helpers/words.rb