Class: Stacked::Question

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, association, collection, find, #initialize, #parse_answers, #parse_badges, #parse_comments, #parse_post_timeline, #parse_questions, #parse_reputations, #parse_tags, #parse_type, #parse_user_timeline, #post, records, request, singular, stats

Constructor Details

This class inherits a constructor from Stacked::Base

Instance Attribute Details

#accepted_answer_idObject

Returns the value of attribute accepted_answer_id.



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

def accepted_answer_id
  @accepted_answer_id
end

#answer_countObject

Returns the value of attribute answer_count.



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

def answer_count
  @answer_count
end

#answersObject

Returns the value of attribute answers.



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

def answers
  @answers
end

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#bounty_closes_dateObject

Returns the value of attribute bounty_closes_date.



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

def bounty_closes_date
  @bounty_closes_date
end

#community_ownedObject

Returns the value of attribute community_owned.



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

def community_owned
  @community_owned
end

#creation_dateObject Also known as: created_at

Returns the value of attribute creation_date.



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

def creation_date
  @creation_date
end

#down_vote_countObject Also known as: down_votes

Returns the value of attribute down_vote_count.



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

def down_vote_count
  @down_vote_count
end

#favorite_countObject Also known as: favorites, favourites

Returns the value of attribute favorite_count.



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

def favorite_count
  @favorite_count
end

#last_activity_dateObject

Returns the value of attribute last_activity_date.



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

def last_activity_date
  @last_activity_date
end

#last_edit_dateObject Also known as: updated_at

Returns the value of attribute last_edit_date.



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

def last_edit_date
  @last_edit_date
end

#owner_display_nameObject

Returns the value of attribute owner_display_name.



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

def owner_display_name
  @owner_display_name
end

#owner_user_idObject

Returns the value of attribute owner_user_id.



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

def owner_user_id
  @owner_user_id
end

#question_idObject Also known as: id

Returns the value of attribute question_id.



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

def question_id
  @question_id
end

#scoreObject

Returns the value of attribute score.



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

def score
  @score
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#up_vote_countObject Also known as: up_votes

Returns the value of attribute up_vote_count.



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

def up_vote_count
  @up_vote_count
end

#view_countObject Also known as: views

Returns the value of attribute view_count.



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

def view_count
  @view_count
end

Class Method Details

.tagged(options = {}) ⇒ Object

All questions tagged with the given tags. Accepts tags as either :tags or :tagged Must be an Array of tags.



78
79
80
81
82
# File 'lib/stacked/question.rb', line 78

def tagged(options={})
  options[:tagged] ||= []
  options[:tagged] = (options[:tagged] << options[:tags]).join(", ")
  records(path + "tagged", options)
end

.unanswered_by_votes(options = {}) ⇒ Object

All unanswered questions ordered by votes.



71
72
73
# File 'lib/stacked/question.rb', line 71

def unanswered_by_votes(options={})
  records(path + "unanswered/votes", options)
end

Instance Method Details

#accepted_answerObject

The Stacked::Answer representing the accepted answer. nil if none accepted



38
39
40
# File 'lib/stacked/question.rb', line 38

def accepted_answer
  Answer.find(accepted_answer_id) if accepted_answer_id
end

#ownerObject Also known as: user

The Stacked::User representation of the owner.



43
44
45
# File 'lib/stacked/question.rb', line 43

def owner
  @owner ||= User.find(owner_user_id)
end

#timeline(options = {}) ⇒ Object

A timeline of the question.



48
49
50
# File 'lib/stacked/question.rb', line 48

def timeline(options={})
  parse_post_timeline(request(singular(id) + "timeline", options))
end