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)



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

def answer_count
  @answer_count
end

#authorString (readonly)



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

def author
  @author
end

#author_idFixnum (readonly)



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

def author_id
  @author_id
end

#book_countFixnum (readonly)



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

def book_count
  @book_count
end

#comment_countFixnum (readonly)



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

def comment_count
  @comment_count
end

#creation_dateString (readonly)



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

def creation_date
  @creation_date
end

#has_acceptedBoolean (readonly)



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

def has_accepted
  @has_accepted
end

#idFixnum (readonly)



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

def id
  @id
end

#lastedit_dateString (readonly)



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

def lastedit_date
  @lastedit_date
end

#lastedit_user_idFixnum (readonly)



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

def lastedit_user_id
  @lastedit_user_id
end

#parent_idFixnum (readonly)



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

def parent_id
  @parent_id
end

#rankFixnum (readonly)



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

def rank
  @rank
end

#reply_countFixnum (readonly)



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

def reply_count
  @reply_count
end

#root_idFixnum (readonly)



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

def root_id
  @root_id
end

#statusString (readonly)



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

def status
  @status
end

#status_idFixnum (readonly)



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

def status_id
  @status_id
end

#subs_countFixnum (readonly)



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

def subs_count
  @subs_count
end

#tag_valString (readonly)



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

def tag_val
  @tag_val
end

#thread_scoreFixnum (readonly)



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

def thread_score
  @thread_score
end

#titleString (readonly)



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

def title
  @title
end

#typeString (readonly)



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

def type
  @type
end

#type_idFixnum (readonly)



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

def type_id
  @type_id
end

#urlString (readonly)



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

def url
  @url
end

#view_countFixnum (readonly)



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

def view_count
  @view_count
end

#vote_countFixnum (readonly)



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

def vote_count
  @vote_count
end

#xhtmlString (readonly)



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.

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