Class: Rubyoverflow::Answer

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyoverflow/answer.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 = '') ⇒ Answer

Returns a new instance of Answer.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rubyoverflow/answer.rb', line 7

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

  @answer_id = dash.answer_id
  @accepted = dash.accepted
  @answer_comments_url = dash.answer_comments_url
  @question_id = dash.question_id
  @locked_date = dash.locked_date
  @owner = User.new 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
  @comments = Comments.new dash.comments if dash.comments
end

Instance Attribute Details

#acceptedObject (readonly)

Returns the value of attribute accepted.



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

def accepted
  @accepted
end

#answer_comments_urlObject (readonly)

Returns the value of attribute answer_comments_url.



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

def answer_comments_url
  @answer_comments_url
end

#answer_idObject (readonly)

Returns the value of attribute answer_id.



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

def answer_id
  @answer_id
end

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#commentsObject (readonly)

Returns the value of attribute comments.



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

def comments
  @comments
end

#community_ownedObject (readonly)

Returns the value of attribute community_owned.



3
4
5
# File 'lib/rubyoverflow/answer.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/answer.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/answer.rb', line 3

def down_vote_count
  @down_vote_count
end

#last_activity_dateObject (readonly)

Returns the value of attribute last_activity_date.



3
4
5
# File 'lib/rubyoverflow/answer.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/answer.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/answer.rb', line 3

def locked_date
  @locked_date
end

#ownerObject (readonly)

Returns the value of attribute owner.



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

def owner
  @owner
end

#question_idObject (readonly)

Returns the value of attribute question_id.



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

def question_id
  @question_id
end

#scoreObject (readonly)

Returns the value of attribute score.



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

def score
  @score
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/rubyoverflow/answer.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/answer.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/answer.rb', line 3

def view_count
  @view_count
end

Instance Method Details

#get_comments(parameters = {}) ⇒ Object

Gets the comments made on the answer



30
31
32
33
34
35
36
37
# File 'lib/rubyoverflow/answer.rb', line 30

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