Class: Rubyoverflow::PostTimelineEvent

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

Returns a new instance of PostTimelineEvent.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rubyoverflow/postTimelineEvent.rb', line 16

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

  @timeline_type = dash.timeline_type
  @post_id = dash.post_id
  @comment_id = dash.comment_id
  @question_id = dash.question_id
  @revision_guid = dash.revision_guid
  @creation_date = dash.creation_date
  @user = User.new dash.user if dash.user
  @owner = User.new dash.owner if dash.owner
  @action = dash.action
  @post_revision_url = dash.post_revision_url
  @post_url = dash.post_url
  @post_comment_url = dash.post_comment_url
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



11
12
13
# File 'lib/rubyoverflow/postTimelineEvent.rb', line 11

def action
  @action
end

#comment_idObject (readonly)

Returns the value of attribute comment_id.



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

def comment_id
  @comment_id
end

#creation_dateObject (readonly)

Returns the value of attribute creation_date.



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

def creation_date
  @creation_date
end

#ownerObject (readonly)

Returns the value of attribute owner.



10
11
12
# File 'lib/rubyoverflow/postTimelineEvent.rb', line 10

def owner
  @owner
end

#post_comment_urlObject (readonly)

Returns the value of attribute post_comment_url.



14
15
16
# File 'lib/rubyoverflow/postTimelineEvent.rb', line 14

def post_comment_url
  @post_comment_url
end

#post_idObject (readonly)

Returns the value of attribute post_id.



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

def post_id
  @post_id
end

#post_revision_urlObject (readonly)

Returns the value of attribute post_revision_url.



12
13
14
# File 'lib/rubyoverflow/postTimelineEvent.rb', line 12

def post_revision_url
  @post_revision_url
end

#post_urlObject (readonly)

Returns the value of attribute post_url.



13
14
15
# File 'lib/rubyoverflow/postTimelineEvent.rb', line 13

def post_url
  @post_url
end

#question_idObject (readonly)

Returns the value of attribute question_id.



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

def question_id
  @question_id
end

#revision_guidObject (readonly)

Returns the value of attribute revision_guid.



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

def revision_guid
  @revision_guid
end

#timeline_typeObject (readonly)

Returns the value of attribute timeline_type.



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

def timeline_type
  @timeline_type
end

#userObject (readonly)

Returns the value of attribute user.



9
10
11
# File 'lib/rubyoverflow/postTimelineEvent.rb', line 9

def user
  @user
end

Instance Method Details

#get_parent_question(parameters = {}) ⇒ Object

Gets the question that this postTimleineEvent belongs to



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

def get_parent_question(parameters={})
  if @question_id
    Questions.retrieve_by_id @question_id
  else
    nil
  end
end

#get_post(parameters = {}) ⇒ Object

Gets the post associated with this postTimelineEvent



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rubyoverflow/postTimelineEvent.rb', line 34

def get_post(parameters={})
  if @post_url
    hash,url = request(@post_url, parameters)
    if @post_url.include? 'question'
      Questions.new hash, url 
    elsif @post_url.include? 'answer'
      Answers.new hash, url
    end
  else
    nil
  end
end

#get_post_comment(parameters = {}) ⇒ Object

Gets the comment associated with this postTimelineEvent



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

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

#get_post_revision(parameters = {}) ⇒ Object

Gets the revision associated with this postTimelineEvent



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

def get_post_revision(parameters={})
  if @post_revision_url
    hash,url = request(@post_revision_url, parameters) 
    Revisions.new hash, url
  else
    nil
  end
end