Class: Biostars::API::Vote

Inherits:
Object
  • Object
show all
Defined in:
lib/biostars/api/vote.rb

Overview

General info about a vote.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#authorString (readonly)

Returns author name.

Returns:

  • (String)

    author name.



9
10
11
# File 'lib/biostars/api/vote.rb', line 9

def author
  @author
end

#author_idFixnum (readonly)

Returns author’s identifier, a number.

Returns:

  • (Fixnum)

    author’s identifier, a number.



12
13
14
# File 'lib/biostars/api/vote.rb', line 12

def author_id
  @author_id
end

#dateString (readonly)

Returns date of the vote, ISO 8601 format.

Returns:

  • (String)

    date of the vote, ISO 8601 format.



15
16
17
# File 'lib/biostars/api/vote.rb', line 15

def date
  @date
end

#idFixnum (readonly)

Returns identifier of the vote, a number.

Returns:

  • (Fixnum)

    identifier of the vote, a number.



18
19
20
# File 'lib/biostars/api/vote.rb', line 18

def id
  @id
end

#post_idFixnum (readonly)

Returns identifier of the voted post.

Returns:

  • (Fixnum)

    identifier of the voted post.



21
22
23
# File 'lib/biostars/api/vote.rb', line 21

def post_id
  @post_id
end

#typeString (readonly)

Returns type of vote.

Returns:

  • (String)

    type of vote.



24
25
26
# File 'lib/biostars/api/vote.rb', line 24

def type
  @type
end

#type_idFixnum (readonly)

Returns type’s identifier for this vote.

Returns:

  • (Fixnum)

    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.

Parameters:

  • id (Fixnum)

    vote id.

Returns:

  • (Vote)

    returns Vote object.

Raises:



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