Class: Biostars::API::Vote
- Inherits:
-
Object
- Object
- Biostars::API::Vote
- Defined in:
- lib/biostars/api/vote.rb
Overview
General info about a vote.
Instance Attribute Summary collapse
-
#author ⇒ String
readonly
Author name.
-
#author_id ⇒ Fixnum
readonly
Author’s identifier, a number.
-
#date ⇒ String
readonly
Date of the vote, ISO 8601 format.
-
#id ⇒ Fixnum
readonly
Identifier of the vote, a number.
-
#post_id ⇒ Fixnum
readonly
Identifier of the voted post.
-
#type ⇒ String
readonly
Type of vote.
-
#type_id ⇒ Fixnum
readonly
Type’s identifier for this vote.
Class Method Summary collapse
-
.find(id) ⇒ Vote
Finds vote with the given id.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Vote
constructor
Instantiate the Biostars::API::Vote.
Constructor Details
#initialize(attributes) ⇒ Vote
Instantiate the Biostars::API::Vote.
30 31 32 33 34 |
# File 'lib/biostars/api/vote.rb', line 30 def initialize(attributes) attributes.each do |k,v| instance_variable_set "@#{k}", v unless v.nil? end end |
Instance Attribute Details
#author ⇒ String (readonly)
Returns author name.
9 10 11 |
# File 'lib/biostars/api/vote.rb', line 9 def end |
#author_id ⇒ Fixnum (readonly)
Returns author’s identifier, a number.
12 13 14 |
# File 'lib/biostars/api/vote.rb', line 12 def end |
#date ⇒ String (readonly)
Returns date of the vote, ISO 8601 format.
15 16 17 |
# File 'lib/biostars/api/vote.rb', line 15 def date @date end |
#id ⇒ Fixnum (readonly)
Returns identifier of the vote, a number.
18 19 20 |
# File 'lib/biostars/api/vote.rb', line 18 def id @id end |
#post_id ⇒ Fixnum (readonly)
Returns identifier of the voted post.
21 22 23 |
# File 'lib/biostars/api/vote.rb', line 21 def post_id @post_id end |
#type ⇒ String (readonly)
Returns type of vote.
24 25 26 |
# File 'lib/biostars/api/vote.rb', line 24 def type @type end |
#type_id ⇒ Fixnum (readonly)
Returns type’s identifier for this vote.
27 28 29 |
# File 'lib/biostars/api/vote.rb', line 27 def type_id @type_id end |
Class Method Details
.find(id) ⇒ Vote
Finds vote with the given id.
41 42 43 44 |
# File 'lib/biostars/api/vote.rb', line 41 def self.find(id) attributes = Biostars::API.get "vote/#{id}" attributes ? new(attributes) : raise(Biostars::VoteError) end |