Class: Redd::Object::Comment

Inherits:
Thing show all
Includes:
Thing::Editable, Thing::Inboxable, Thing::Moderatable, Thing::Reportable, Thing::Voteable
Defined in:
lib/redd/object/comment.rb

Overview

A comment made on links.

Instance Attribute Summary collapse

Attributes inherited from Thing

#id, #kind

Attributes inherited from Base

#attributes, #client

Instance Method Summary collapse

Methods included from Thing::Voteable

#downvote, #unvote, #upvote

Methods included from Thing::Reportable

#report

Methods included from Thing::Moderatable

#approve, #distinguish, #ignore_reports, #remove, #undistinguish, #unignore_reports

Methods included from Thing::Inboxable

#mark_as_read, #mark_as_unread, #reply

Methods included from Thing::Editable

#delete, #edit

Methods inherited from Thing

#==, #fullname

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, #initialize

Constructor Details

This class inherits a constructor from Redd::Base

Instance Attribute Details

#approved_byObject (readonly)

Returns the value of attribute approved_by.



32
33
34
# File 'lib/redd/object/comment.rb', line 32

def approved_by
  @approved_by
end

#authorObject (readonly)

Returns the value of attribute author.



19
20
21
# File 'lib/redd/object/comment.rb', line 19

def author
  @author
end

#author_flair_css_classObject (readonly)

Returns the value of attribute author_flair_css_class.



42
43
44
# File 'lib/redd/object/comment.rb', line 42

def author_flair_css_class
  @author_flair_css_class
end

#author_flair_textObject (readonly)

Returns the value of attribute author_flair_text.



41
42
43
# File 'lib/redd/object/comment.rb', line 41

def author_flair_text
  @author_flair_text
end

#banned_byObject (readonly)

Returns the value of attribute banned_by.



31
32
33
# File 'lib/redd/object/comment.rb', line 31

def banned_by
  @banned_by
end

#bodyObject (readonly)

Returns the value of attribute body.



39
40
41
# File 'lib/redd/object/comment.rb', line 39

def body
  @body
end

#body_htmlObject (readonly)

Returns the value of attribute body_html.



40
41
42
# File 'lib/redd/object/comment.rb', line 40

def body_html
  @body_html
end

#controversialityObject (readonly)

Returns the value of attribute controversiality.



29
30
31
# File 'lib/redd/object/comment.rb', line 29

def controversiality
  @controversiality
end

#distinguishedObject (readonly)

Returns the value of attribute distinguished.



34
35
36
# File 'lib/redd/object/comment.rb', line 34

def distinguished
  @distinguished
end

#downsObject (readonly)

Returns the value of attribute downs.



26
27
28
# File 'lib/redd/object/comment.rb', line 26

def downs
  @downs
end

#editedObject (readonly)

Returns the value of attribute edited.



21
22
23
# File 'lib/redd/object/comment.rb', line 21

def edited
  @edited
end

#gildedObject (readonly)

Returns the value of attribute gilded.



23
24
25
# File 'lib/redd/object/comment.rb', line 23

def gilded
  @gilded
end

#likesObject (readonly)

Returns the value of attribute likes.



28
29
30
# File 'lib/redd/object/comment.rb', line 28

def likes
  @likes
end

Returns the value of attribute link_id.



38
39
40
# File 'lib/redd/object/comment.rb', line 38

def link_id
  @link_id
end

#num_reportsObject (readonly) Also known as: reports_count

Returns the value of attribute num_reports.



35
36
37
# File 'lib/redd/object/comment.rb', line 35

def num_reports
  @num_reports
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



37
38
39
# File 'lib/redd/object/comment.rb', line 37

def parent_id
  @parent_id
end

#savedObject (readonly)

Returns the value of attribute saved.



22
23
24
# File 'lib/redd/object/comment.rb', line 22

def saved
  @saved
end

#scoreObject (readonly)

Returns the value of attribute score.



27
28
29
# File 'lib/redd/object/comment.rb', line 27

def score
  @score
end

#score_hiddenObject (readonly)

Returns the value of attribute score_hidden.



33
34
35
# File 'lib/redd/object/comment.rb', line 33

def score_hidden
  @score_hidden
end

#upsObject (readonly)

Returns the value of attribute ups.



25
26
27
# File 'lib/redd/object/comment.rb', line 25

def ups
  @ups
end

Instance Method Details

#createdObject



54
55
56
# File 'lib/redd/object/comment.rb', line 54

def created
  @created ||= Time.at(@attributes[:created_utc])
end

#gilded?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/redd/object/comment.rb', line 62

def gilded?
  gilded > 0
end

#repliesObject



46
47
48
# File 'lib/redd/object/comment.rb', line 46

def replies
  @replies ||= client.get_replies(self)
end

#root?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/redd/object/comment.rb', line 58

def root?
  !parent_id || parent_id == link_id
end

#subredditObject



50
51
52
# File 'lib/redd/object/comment.rb', line 50

def subreddit
  @subreddit ||= client.subreddit(@attributes[:subreddit])
end