Class: Biostars::API::Post

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

Overview

General info about a post.

Author:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Post

Instantiate the Biostars::API::Post.



87
88
89
90
91
# File 'lib/biostars/api/post.rb', line 87

def initialize(attributes)
	attributes.each do |k,v| 
		instance_variable_set("@#{k}", v) unless v.nil?
	end
end

Instance Attribute Details

#answer_countFixnum (readonly)

Returns number of answers.

Returns:

  • (Fixnum)

    number of answers.



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

def answer_count
  @answer_count
end

#authorString (readonly)

Returns author name.

Returns:

  • (String)

    author name.



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

def author
  @author
end

#author_idFixnum (readonly)

Returns author’s identifier, a number.

Returns:

  • (Fixnum)

    author’s identifier, a number.



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

def author_id
  @author_id
end

#book_countFixnum (readonly)

Returns number of bookmarks.

Returns:

  • (Fixnum)

    number of bookmarks.



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

def book_count
  @book_count
end

#comment_countFixnum (readonly)

Returns number of comments.

Returns:

  • (Fixnum)

    number of comments.



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

def comment_count
  @comment_count
end

#creation_dateString (readonly)

Returns creation date, ISO 8601 format.

Returns:

  • (String)

    creation date, ISO 8601 format.



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

def creation_date
  @creation_date
end

#has_acceptedBoolean (readonly)

Returns true if the question has an accepted answer, boolean.

Returns:

  • (Boolean)

    true if the question has an accepted answer, boolean.



27
28
29
# File 'lib/biostars/api/post.rb', line 27

def has_accepted
  @has_accepted
end

#idFixnum (readonly)

Returns identifier of the post, a number.

Returns:

  • (Fixnum)

    identifier of the post, a number.



30
31
32
# File 'lib/biostars/api/post.rb', line 30

def id
  @id
end

#lastedit_dateString (readonly)

Returns date of last edit, ISO 8601 format.

Returns:

  • (String)

    date of last edit, ISO 8601 format.



33
34
35
# File 'lib/biostars/api/post.rb', line 33

def lastedit_date
  @lastedit_date
end

#lastedit_user_idFixnum (readonly)

Returns user who last edited this post.

Returns:

  • (Fixnum)

    user who last edited this post.



36
37
38
# File 'lib/biostars/api/post.rb', line 36

def lastedit_user_id
  @lastedit_user_id
end

#parent_idFixnum (readonly)

Returns identifier of the parent post.

Returns:

  • (Fixnum)

    identifier of the parent post.



39
40
41
# File 'lib/biostars/api/post.rb', line 39

def parent_id
  @parent_id
end

#rankFixnum (readonly)

Returns rank, a number.

Returns:

  • (Fixnum)

    rank, a number.



42
43
44
# File 'lib/biostars/api/post.rb', line 42

def rank
  @rank
end

#reply_countFixnum (readonly)

Returns number of replies.

Returns:

  • (Fixnum)

    number of replies.



45
46
47
# File 'lib/biostars/api/post.rb', line 45

def reply_count
  @reply_count
end

#root_idFixnum (readonly)

Returns identifier of the root post.

Returns:

  • (Fixnum)

    identifier of the root post.



48
49
50
# File 'lib/biostars/api/post.rb', line 48

def root_id
  @root_id
end

#statusString (readonly)

Returns status message.

Returns:

  • (String)

    status message.



51
52
53
# File 'lib/biostars/api/post.rb', line 51

def status
  @status
end

#status_idFixnum (readonly)

Returns status’ identifier, a number.

Returns:

  • (Fixnum)

    status’ identifier, a number.



54
55
56
# File 'lib/biostars/api/post.rb', line 54

def status_id
  @status_id
end

#subs_countFixnum (readonly)

Returns number of subscribers following this post.

Returns:

  • (Fixnum)

    number of subscribers following this post.



57
58
59
# File 'lib/biostars/api/post.rb', line 57

def subs_count
  @subs_count
end

#tag_valString (readonly)

Returns tags.

Returns:

  • (String)

    tags.



60
61
62
# File 'lib/biostars/api/post.rb', line 60

def tag_val
  @tag_val
end

#thread_scoreFixnum (readonly)

Returns thread’s score.

Returns:

  • (Fixnum)

    thread’s score.



63
64
65
# File 'lib/biostars/api/post.rb', line 63

def thread_score
  @thread_score
end

#titleString (readonly)

Returns title.

Returns:

  • (String)

    title.



66
67
68
# File 'lib/biostars/api/post.rb', line 66

def title
  @title
end

#typeString (readonly)

Returns type of post.

Returns:

  • (String)

    type of post.



69
70
71
# File 'lib/biostars/api/post.rb', line 69

def type
  @type
end

#type_idFixnum (readonly)

Returns type’s identifier for this post.

Returns:

  • (Fixnum)

    type’s identifier for this post.



72
73
74
# File 'lib/biostars/api/post.rb', line 72

def type_id
  @type_id
end

#urlString (readonly)

Returns url.

Returns:

  • (String)

    url.



75
76
77
# File 'lib/biostars/api/post.rb', line 75

def url
  @url
end

#view_countFixnum (readonly)

Returns number of views.

Returns:

  • (Fixnum)

    number of views.



78
79
80
# File 'lib/biostars/api/post.rb', line 78

def view_count
  @view_count
end

#vote_countFixnum (readonly)

Returns number of votes.

Returns:

  • (Fixnum)

    number of votes.



81
82
83
# File 'lib/biostars/api/post.rb', line 81

def vote_count
  @vote_count
end

#xhtmlString (readonly)

Returns content.

Returns:

  • (String)

    content.



84
85
86
# File 'lib/biostars/api/post.rb', line 84

def xhtml
  @xhtml
end

Class Method Details

.find(id) ⇒ Post

Finds post with the given id.

Parameters:

  • id (Fixnum)

    post id.

Returns:

  • (Post)

    returns Post object.

Raises:



98
99
100
101
# File 'lib/biostars/api/post.rb', line 98

def self.find(id)
	attributes = Biostars::API.get "post/#{id}"
	attributes ? new(attributes) : raise(Biostars::PostError)
end