Class: API::StackOverflow::Answer

Inherits:
Object
  • Object
show all
Defined in:
lib/answer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(so_answer) ⇒ Answer

Returns a new instance of Answer.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/answer.rb', line 8

def initialize(so_answer)
  @id = so_answer["answer_id"]
  @title = so_answer["title"]
  @accepted = so_answer["accepted"]
  @comments_url = so_answer["answer_comments_url"]
  @question_id = so_answer["question_id"]
  @creation_date = Time.at(so_answer["creation_date"]) if so_answer["creation_date"]
  @last_activity_date = Time.at(so_answer["last_activity_date"]) if so_answer["last_activity_date"]
  @up_vote_count = so_answer["up_vote_count"]
  @down_vote_count = so_answer["down_vote_count"]
  @view_count = so_answer["view_count"]
  @score = so_answer["score"]
  @community_owned = so_answer["community_owned"]
end

Instance Attribute Details

#acceptedObject

Returns the value of attribute accepted.



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

def accepted
  @accepted
end

#comments_urlObject

Returns the value of attribute comments_url.



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

def comments_url
  @comments_url
end

#community_ownedObject

Returns the value of attribute community_owned.



6
7
8
# File 'lib/answer.rb', line 6

def community_owned
  @community_owned
end

#creation_dateObject

Returns the value of attribute creation_date.



5
6
7
# File 'lib/answer.rb', line 5

def creation_date
  @creation_date
end

#down_vote_countObject

Returns the value of attribute down_vote_count.



6
7
8
# File 'lib/answer.rb', line 6

def down_vote_count
  @down_vote_count
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#last_activity_dateObject

Returns the value of attribute last_activity_date.



5
6
7
# File 'lib/answer.rb', line 5

def last_activity_date
  @last_activity_date
end

#question_idObject

Returns the value of attribute question_id.



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

def question_id
  @question_id
end

#scoreObject

Returns the value of attribute score.



6
7
8
# File 'lib/answer.rb', line 6

def score
  @score
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#up_vote_countObject

Returns the value of attribute up_vote_count.



6
7
8
# File 'lib/answer.rb', line 6

def up_vote_count
  @up_vote_count
end

#view_countObject

Returns the value of attribute view_count.



6
7
8
# File 'lib/answer.rb', line 6

def view_count
  @view_count
end

Instance Method Details

#vote_countObject



23
24
25
# File 'lib/answer.rb', line 23

def vote_count
  @up_vote_count - @down_vote_count
end