module NeonRAW::Objects::Thing::Votable

Methods for objects that you can cast votes on. @!attribute [r] ups

@return [Integer] Returns the number of upvotes the thing has.

@!attribute [r] downs

@return [Integer] Returns the number of downvotes the thing has.

Public Instance Methods

downvoted?() click to toggle source

Checks whether or not you downvoted the thing. @!method downvoted? @return [Boolean] Returns whether or not you downvoted the thing.

# File lib/NeonRAW/objects/thing/votable.rb, line 35
def downvoted?
  if @likes == false
    true
  else
    false
  end
end
upvoted?() click to toggle source

Checks whether or not you upvoted the thing. @!method upvoted? @return [Boolean] Returns whether or not you upvoted the thing.

# File lib/NeonRAW/objects/thing/votable.rb, line 24
def upvoted?
  if @likes == true
    true
  else
    false
  end
end
voted?() click to toggle source

Checks whether you voted on the thing. @!method voted? @return [Boolean] Returns whether or not you voted on the thing.

# File lib/NeonRAW/objects/thing/votable.rb, line 13
def voted?
  if @likes.nil?
    false
  else
    true
  end
end

Private Instance Methods

votes() click to toggle source

Contains the values for each type of vote. @!method votes @return [Hash] Returns a hash containing the vote values.

# File lib/NeonRAW/objects/thing/votable.rb, line 46
def votes
  {
    upvote: 1,
    clear_vote: 0,
    downvote: -1
  }
end