Class: API::StackOverflow::Question

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(so_question) ⇒ Question

Returns a new instance of Question.



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

def initialize(so_question)
  @id = so_question["question_id"]
  @answer_count = so_question["answer_count"]
  @accepted_answer_id = so_question["accepted_answer_id"]
  @favorite_count = so_question["favorite_count"]
  @timeline_url = so_question["question_timeline_url"]
  @comments_url = so_question["question_comments_url"]
  @answers_url = so_question["question_answers_url"]
  @creation_date = Time.at(so_question["creation_date"]) if so_question["creation_date"]
  @last_edit_date = Time.at(so_question["last_edit_date"]) if so_question["last_edit_date"]
  @last_activity_date = Time.at(so_question["last_activity_date"]) if so_question["last_activity_date"]
  @up_vote_count = so_question["up_vote_count"]
  @down_vote_count = so_question["down_vote_count"]
  @view_count = so_question["view_count"]
  @score = so_question["score"]
  @community_owned = so_question["community_owned"]
  @title = so_question["title"]
end

Instance Attribute Details

#accepted_answer_idObject

Returns the value of attribute accepted_answer_id.



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

def accepted_answer_id
  @accepted_answer_id
end

#answer_countObject

Returns the value of attribute answer_count.



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

def answer_count
  @answer_count
end

#answers_urlObject

Returns the value of attribute answers_url.



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

def answers_url
  @answers_url
end

#comments_urlObject

Returns the value of attribute comments_url.



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

def comments_url
  @comments_url
end

#community_ownedObject

Returns the value of attribute community_owned.



8
9
10
# File 'lib/question.rb', line 8

def community_owned
  @community_owned
end

#creation_dateObject

Returns the value of attribute creation_date.



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

def creation_date
  @creation_date
end

#down_vote_countObject

Returns the value of attribute down_vote_count.



7
8
9
# File 'lib/question.rb', line 7

def down_vote_count
  @down_vote_count
end

#favorite_countObject

Returns the value of attribute favorite_count.



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

def favorite_count
  @favorite_count
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#last_activity_dateObject

Returns the value of attribute last_activity_date.



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

def last_activity_date
  @last_activity_date
end

#last_edit_dateObject

Returns the value of attribute last_edit_date.



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

def last_edit_date
  @last_edit_date
end

#scoreObject

Returns the value of attribute score.



7
8
9
# File 'lib/question.rb', line 7

def score
  @score
end

#timeline_urlObject

Returns the value of attribute timeline_url.



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

def timeline_url
  @timeline_url
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/question.rb', line 8

def title
  @title
end

#up_vote_countObject

Returns the value of attribute up_vote_count.



7
8
9
# File 'lib/question.rb', line 7

def up_vote_count
  @up_vote_count
end

#view_countObject

Returns the value of attribute view_count.



7
8
9
# File 'lib/question.rb', line 7

def view_count
  @view_count
end

Instance Method Details

#vote_countObject



29
30
31
# File 'lib/question.rb', line 29

def vote_count
  @up_vote_count - @down_vote_count
end