Module: RedditKit::Votable

Included in:
Comment, Link
Defined in:
lib/redditkit/votable.rb

Overview

Methods which determine the voting status of objects.

Instance Method Summary collapse

Instance Method Details

#downvoted?Boolean

Whether the current user has downvotes this item.

Returns:

  • (Boolean)


27
28
29
# File 'lib/redditkit/votable.rb', line 27

def downvoted?
  @attributes[:likes] == false
end

#downvotesObject

The number of downvotes an item has.



12
13
14
# File 'lib/redditkit/votable.rb', line 12

def downvotes
  @attributes[:downs]
end

#scoreObject

The score for an item.



17
18
19
# File 'lib/redditkit/votable.rb', line 17

def score
  @attributes[:score]
end

#upvoted?Boolean

Whether the current user has upvoted this item.

Returns:

  • (Boolean)


22
23
24
# File 'lib/redditkit/votable.rb', line 22

def upvoted?
  @attributes[:likes] == true
end

#upvotesObject

The number of upvotes an item has.



7
8
9
# File 'lib/redditkit/votable.rb', line 7

def upvotes
  @attributes[:ups]
end

#voted?Boolean

Whether the user has voted on this item (either upvoted or downvoted).

Returns:

  • (Boolean)


32
33
34
# File 'lib/redditkit/votable.rb', line 32

def voted?
  !@attributes[:likes].nil?
end