Class: NeonRAW::Objects::Comment

Inherits:
Thing
  • Object
show all
Includes:
Thing::Createable, Thing::Editable, Thing::Gildable, Thing::Inboxable, Thing::Moderateable, Thing::Refreshable, Thing::Repliable, Thing::Saveable, Thing::Votable
Defined in:
lib/NeonRAW/objects/comment.rb

Overview

The comment object.

Instance Attribute Summary collapse

Attributes included from Thing::Votable

#downs, #ups

Attributes included from Thing::Moderateable

#mod_reports, #user_reports

Attributes inherited from Thing

#id, #name

Instance Method Summary collapse

Methods included from Thing::Votable

#clear_vote, #downvote, #downvoted?, #upvote, #upvoted?, #voted?

Methods included from Thing::Saveable

#save, #unsave

Methods included from Thing::Repliable

#reply

Methods included from Thing::Refreshable

#refresh!

Methods included from Thing::Moderateable

#approve!, #distinguish!, #distinguished?, #distinguished_by, #ignore_reports!, #remove!, #report, #spam!, #stickied?, #unignore_reports!

Methods included from Thing::Inboxable

#mark_as_read, #mark_as_unread, #reply

Methods included from Thing::Gildable

#gild, #gilded?

Methods included from Thing::Editable

#delete!, #edit!, #edited?, #last_edit

Methods included from Thing::Createable

#created, #created_utc

Constructor Details

#initialize(client, data) ⇒ Comment

Returns a new instance of Comment.

Parameters:

  • client (NeonRAW::Clients::Web/Installed/Script)

    The client object.

  • data (Hash)

    The comment data.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/NeonRAW/objects/comment.rb', line 81

def initialize(client, data)
  @client = client
  data.each do |key, value|
    # for consistency, empty strings/arrays/hashes are set to nil
    # because most of the keys returned by Reddit are nil when they
    # don't have a value, besides a few
    value = nil if ['', [], {}].include?(value)
    instance_variable_set(:"@#{key}", value)
    next if %i[created created_utc replies].include?(key)
    self.class.send(:attr_reader, key)
  end
  class << self
    alias_method :removed_by, :banned_by
    alias_method :gold_count, :gilded
    alias_method :saved?, :saved
    alias_method :score_hidden?, :score_hidden
    alias_method :archived?, :archived
    alias_method :link_name, :link_id
    alias_method :parent_name, :parent_id
  end
end

Instance Attribute Details

#approved_byString? (readonly)

Returns which mod approved the comment or nil if none did or you aren’t a moderator of that subreddit.

Returns:

  • (String, nil)

    Returns which mod approved the comment or nil if none did or you aren’t a moderator of that subreddit.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#archived?Boolean (readonly)

Returns whether or not the comment is archived.

Returns:

  • (Boolean)

    Returns whether or not the comment is archived.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#authorString (readonly)

Returns the author of the comment.

Returns:

  • (String)

    Returns the author of the comment.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#author_flair_css_classString? (readonly)

Returns the author’s flair CSS class or nil if there is none.

Returns:

  • (String, nil)

    Returns the author’s flair CSS class or nil if there is none.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#author_flair_textString? (readonly)

Returns the author’s flair text or nil if there is none.

Returns:

  • (String, nil)

    Returns the author’s flair text or nil if there is none.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#bodyString? (readonly)

Returns the text body of the comment or nil if there isn’t one.

Returns:

  • (String, nil)

    Returns the text body of the comment or nil if there isn’t one.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#body_htmlString? (readonly)

Returns the text body of the comment with HTML or nil if there isn’t one.

Returns:

  • (String, nil)

    Returns the text body of the comment with HTML or nil if there isn’t one.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#gold_countInteger (readonly)

Returns the amount of gold a comment has been given.

Returns:

  • (Integer)

    Returns the amount of gold a comment has been given.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end
Note:

This attribute only exists if the comment is fetched from outside the thread it was posted in (so like user pages, /r/subreddit/comments, that type of stuff).

Returns the author of the submission link that the comment was made in response to.

Returns:

  • (String)

    Returns the author of the submission link that the comment was made in response to.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

Returns the name of the link that this comment is in.

Returns:

  • (String)

    Returns the name of the link that this comment is in.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end
Note:

This attribute only exists if the comment is fetched from outside the thread it was posted in (so like user pages, /r/subreddit/comments, that type of stuff).

Returns the title of the parent link.

Returns:

  • (String)

    Returns the title of the parent link.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end
Note:

This attribute only exists if the comment is fetched from outside the thread it was posted in (so like user pages, /r/subreddit/comments, that type of stuff).

Returns the URL of the parent link.

Returns:

  • (String)

    Returns the URL of the parent link.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#num_reportsInteger? (readonly)

Returns the number of times the comment has been reported or nil if it hasn’t or you aren’t a moderator.

Returns:

  • (Integer, nil)

    Returns the number of times the comment has been reported or nil if it hasn’t or you aren’t a moderator.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#parent_nameString (readonly)

Returns the name of either the link or the comment that this comment is a reply to.

Returns:

  • (String)

    Returns the name of either the link or the comment that this comment is a reply to.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#removed_byString? (readonly)

Returns which mod removed the comment or nil if none did or you aren’t a moderator of that subreddit.

Returns:

  • (String, nil)

    Returns which mod removed the comment or nil if none did or you aren’t a moderator of that subreddit.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#saved?Boolean (readonly)

Returns whether or not you saved the comment.

Returns:

  • (Boolean)

    Returns whether or not you saved the comment.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#scoreInteger (readonly)

Returns the karma score of the comment.

Returns:

  • (Integer)

    Returns the karma score of the comment.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#score_hidden?Boolean (readonly)

Returns whether or not the karma score of the comment is hidden.

Returns:

  • (Boolean)

    Returns whether or not the karma score of the comment is hidden.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#subredditString (readonly)

Returns the subreddit the comment was posted to.

Returns:

  • (String)

    Returns the subreddit the comment was posted to.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

#subreddit_idString (readonly)

Returns the ID of the subreddit where the comment was posted to.

Returns:

  • (String)

    Returns the ID of the subreddit where the comment was posted to.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/NeonRAW/objects/comment.rb', line 66

class Comment < Thing
  include Thing::Createable
  include Thing::Editable
  include Thing::Gildable
  include Thing::Inboxable
  include Thing::Moderateable
  include Thing::Refreshable
  include Thing::Repliable
  include Thing::Saveable
  include Thing::Votable

  # @!method initialize(client, data)
  # @param client [NeonRAW::Clients::Web/Installed/Script] The client
  #   object.
  # @param data [Hash] The comment data.
  def initialize(client, data)
    @client = client
    data.each do |key, value|
      # for consistency, empty strings/arrays/hashes are set to nil
      # because most of the keys returned by Reddit are nil when they
      # don't have a value, besides a few
      value = nil if ['', [], {}].include?(value)
      instance_variable_set(:"@#{key}", value)
      next if %i[created created_utc replies].include?(key)
      self.class.send(:attr_reader, key)
    end
    class << self
      alias_method :removed_by, :banned_by
      alias_method :gold_count, :gilded
      alias_method :saved?, :saved
      alias_method :score_hidden?, :score_hidden
      alias_method :archived?, :archived
      alias_method :link_name, :link_id
      alias_method :parent_name, :parent_id
    end
  end

  # Returns whether or not the comment is a MoreComments object.
  # @!method morecomments?
  # @return [Boolean] Returns false.
  def morecomments?
    false
  end

  # Checks whether or not this is a submission.
  # @!method submission?
  # @return [Boolean] Returns false.
  def submission?
    false
  end

  # Checks whether or not this is a comment.
  # @!method comment?
  # @return [Boolean] Returns true.
  def comment?
    true
  end

  # Checks whether or not the comment has replies to it.
  # @!method replies?
  # @return [Boolean] Returns whether or not the comment has replies to it.
  def replies?
    if @replies.nil?
      false
    else
      true
    end
  end

  # Gets the replies made to the comment.
  # @!method replies
  # @return [Array<NeonRAW::Objects::Comment,
  #   NeonRAW::Objects::MoreComments>, nil] Returns either a list of the
  #   Comments/MoreComments or nil if there were no replies.
  def replies
    return nil if @replies.nil?
    comments = []
    @replies[:data][:children].each do |reply|
      if reply[:kind] == 't1'
        comments << Comment.new(@client, reply[:data])
      elsif reply[:kind] == 'more'
        comments << MoreComments.new(@client, reply[:data])
      end
    end
    comments
  end

  # Creates the comment's permalink.
  # @!method permalink
  # @return [String] Returns the comment's permalink.
  def permalink
    submission_id = link_id[3..-1] # trims the t3_ from the fullname
    # the // is intentional
    "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
  end
end

Instance Method Details

#comment?Boolean

Checks whether or not this is a comment.

Returns:

  • (Boolean)

    Returns true.



120
121
122
# File 'lib/NeonRAW/objects/comment.rb', line 120

def comment?
  true
end

#morecomments?Boolean

Returns whether or not the comment is a MoreComments object.

Returns:

  • (Boolean)

    Returns false.



106
107
108
# File 'lib/NeonRAW/objects/comment.rb', line 106

def morecomments?
  false
end

Creates the comment’s permalink.

Returns:

  • (String)

    Returns the comment’s permalink.



156
157
158
159
160
# File 'lib/NeonRAW/objects/comment.rb', line 156

def permalink
  submission_id = link_id[3..-1] # trims the t3_ from the fullname
  # the // is intentional
  "https://www.reddit.com/r/#{subreddit}/comments/#{submission_id}//#{id}"
end

#repliesArray<NeonRAW::Objects::Comment, NeonRAW::Objects::MoreComments>?

Gets the replies made to the comment.

Returns:



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/NeonRAW/objects/comment.rb', line 140

def replies
  return nil if @replies.nil?
  comments = []
  @replies[:data][:children].each do |reply|
    if reply[:kind] == 't1'
      comments << Comment.new(@client, reply[:data])
    elsif reply[:kind] == 'more'
      comments << MoreComments.new(@client, reply[:data])
    end
  end
  comments
end

#replies?Boolean

Checks whether or not the comment has replies to it.

Returns:

  • (Boolean)

    Returns whether or not the comment has replies to it.



127
128
129
130
131
132
133
# File 'lib/NeonRAW/objects/comment.rb', line 127

def replies?
  if @replies.nil?
    false
  else
    true
  end
end

#submission?Boolean

Checks whether or not this is a submission.

Returns:

  • (Boolean)

    Returns false.



113
114
115
# File 'lib/NeonRAW/objects/comment.rb', line 113

def submission?
  false
end