Class: Rubyoverflow::Question

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyoverflow/question.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

change_end_point, client, convert_if_array, convert_to_id_list, #find_parse_querystring, request, #request

Constructor Details

#initialize(hash, request_path = '') ⇒ Question

Returns a new instance of Question.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rubyoverflow/question.rb', line 9

def initialize(hash, request_path = '')
  dash = QuestionDash.new hash

  @tags = Array.new
  @comments = Array.new
  @answers = Array.new

  dash.tags.each {|tag| @tags.push(tag)} if dash.tags
  dash.comments.each {|commentHash| @comment.push(Comment.new commentHash)} if dash.comments
  dash.answers.each {|answerHash| @comment.push(Answer.new answerHash)} if dash.answers

  @migrated = dash.migrated
  @answer_count = dash.answer_count
  @accepted_answer_id = dash.accepted_answer_id
  @favorite_count = dash.favorite_count
  @bounty_closes_date = dash.bounty_closes_date
  @bounty_amount = dash.bounty_amount
  @closed_date = dash.closed_date
  @closed_reason = dash.closed_reason
  @question_timeline_url = dash.question_timeline_url
  @question_comments_url = dash.question_comments_url
  @question_answers_url = dash.question_answers_url
  @question_id = dash.question_id
  @locked_date = dash.locked_date
  @owner = User.new dash.owner if dash.owner
  @creation_date = dash.creation_date
  @last_edit_date = dash.last_edit_date
  @last_activity_date = dash.last_activity_date
  @up_vote_count = dash.up_vote_count
  @down_vote_count = dash.down_vote_count
  @view_count = dash.view_count
  @score = dash.score
  @community_owned = dash.community_owned
  @title = dash.title
  @body = dash.body
  @protected_date = dash.protected_date
end

Instance Attribute Details

#accepted_answer_idObject (readonly)

Returns the value of attribute accepted_answer_id.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def accepted_answer_id
  @accepted_answer_id
end

#answer_countObject (readonly)

Returns the value of attribute answer_count.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def answer_count
  @answer_count
end

#answersObject (readonly)

Returns the value of attribute answers.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def answers
  @answers
end

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def body
  @body
end

#bounty_amountObject (readonly)

Returns the value of attribute bounty_amount.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def bounty_amount
  @bounty_amount
end

#bounty_closes_dateObject (readonly)

Returns the value of attribute bounty_closes_date.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def bounty_closes_date
  @bounty_closes_date
end

#closed_dateObject (readonly)

Returns the value of attribute closed_date.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def closed_date
  @closed_date
end

#closed_reasonObject (readonly)

Returns the value of attribute closed_reason.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def closed_reason
  @closed_reason
end

#commentsObject (readonly)

Returns the value of attribute comments.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def comments
  @comments
end

#community_ownedObject (readonly)

Returns the value of attribute community_owned.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def community_owned
  @community_owned
end

#creation_dateObject (readonly)

Returns the value of attribute creation_date.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def creation_date
  @creation_date
end

#down_vote_countObject (readonly)

Returns the value of attribute down_vote_count.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def down_vote_count
  @down_vote_count
end

#favorite_countObject (readonly)

Returns the value of attribute favorite_count.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def favorite_count
  @favorite_count
end

#last_activity_dateObject (readonly)

Returns the value of attribute last_activity_date.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def last_activity_date
  @last_activity_date
end

#last_edit_dateObject (readonly)

Returns the value of attribute last_edit_date.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def last_edit_date
  @last_edit_date
end

#locked_dateObject (readonly)

Returns the value of attribute locked_date.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def locked_date
  @locked_date
end

#migratedObject (readonly)

Returns the value of attribute migrated.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def migrated
  @migrated
end

#ownerObject (readonly)

Returns the value of attribute owner.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def owner
  @owner
end

#protected_dateObject (readonly)

Returns the value of attribute protected_date.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def protected_date
  @protected_date
end

#question_answers_urlObject (readonly)

Returns the value of attribute question_answers_url.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def question_answers_url
  @question_answers_url
end

#question_comments_urlObject (readonly)

Returns the value of attribute question_comments_url.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def question_comments_url
  @question_comments_url
end

#question_idObject (readonly)

Returns the value of attribute question_id.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def question_id
  @question_id
end

#question_timeline_urlObject (readonly)

Returns the value of attribute question_timeline_url.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def question_timeline_url
  @question_timeline_url
end

#scoreObject (readonly)

Returns the value of attribute score.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def score
  @score
end

#tagsObject (readonly)

Returns the value of attribute tags.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def tags
  @tags
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def title
  @title
end

#up_vote_countObject (readonly)

Returns the value of attribute up_vote_count.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def up_vote_count
  @up_vote_count
end

#view_countObject (readonly)

Returns the value of attribute view_count.



3
4
5
# File 'lib/rubyoverflow/question.rb', line 3

def view_count
  @view_count
end

Instance Method Details

#get_answers(parameters = {}) ⇒ Object

Gets the answers posted to the question



58
59
60
61
62
63
64
65
# File 'lib/rubyoverflow/question.rb', line 58

def get_answers(parameters = {})
  if @question_answers_url
    hash,url =request(@question_answers_url, parameters)
    Answers.new hash, url
  else
    nil
  end
end

#get_comments(parameters = {}) ⇒ Object

Gets the comments made on the question



48
49
50
51
52
53
54
55
# File 'lib/rubyoverflow/question.rb', line 48

def get_comments(parameters = {})
  if @question_comments_url
    hash,url =request(@question_comments_url, parameters)
    Comments.new hash, url
  else
    nil
  end
end

#get_timeline(parameters = {}) ⇒ Object

Gets the timeline for the question



68
69
70
71
72
73
74
75
# File 'lib/rubyoverflow/question.rb', line 68

def get_timeline(parameters = {})
  if @question_timeline_url
    hash,url =request(@question_timeline_url, parameters)
    PostTimelineEvents.new hash, url
  else
    nil
  end
end