Class: Redd::Models::PrivateMessage

Inherits:
Model
  • Object
show all
Includes:
Inboxable, Replyable, Reportable
Defined in:
lib/redd/models/private_message.rb

Overview

A private message

Instance Attribute Summary collapse

Attributes inherited from Model

#client

Instance Method Summary collapse

Methods included from Reportable

#report

Methods included from Replyable

#reply

Methods included from Inboxable

#block, #collapse, #mark_as_read, #mark_as_unread, #uncollapse

Methods inherited from Model

#initialize

Constructor Details

This class inherits a constructor from Redd::Models::Model

Instance Attribute Details

#authorUser (readonly)

Returns the message author.

Returns:

  • (User)

    the message author


61
# File 'lib/redd/models/private_message.rb', line 61

property :author, with: ->(n) { User.new(client, name: n) if n }

#bodyString (readonly)

Returns the message body.

Returns:

  • (String)

    the message body


81
# File 'lib/redd/models/private_message.rb', line 81

property :body

#body_htmlString (readonly)

Returns the html-rendered version of the body.

Returns:

  • (String)

    the html-rendered version of the body


85
# File 'lib/redd/models/private_message.rb', line 85

property :body_html

#createdTime (readonly)

Returns the time the message was created.

Returns:

  • (Time)

    the time the message was created


98
# File 'lib/redd/models/private_message.rb', line 98

property :created_utc, with: ->(t) { Time.at(t) }

#destString (readonly)

TODO:

maybe convert the object to Subreddit/User?

Returns the recipient of the message.

Returns:

  • (String)

    the recipient of the message


90
# File 'lib/redd/models/private_message.rb', line 90

property :dest

#distinguishedString (readonly)

Returns the level the message is distinguished.

Returns:

  • (String)

    the level the message is distinguished


102
# File 'lib/redd/models/private_message.rb', line 102

property :distinguished

#first_messageInteger (readonly)

Returns not sure what this does.

Returns:

  • (Integer)

    not sure what this does


33
# File 'lib/redd/models/private_message.rb', line 33

property :first_message

#first_message_nameString (readonly)

Returns the fullname of the first message.

Returns:

  • (String)

    the fullname of the first message


37
# File 'lib/redd/models/private_message.rb', line 37

property :first_message_name

#idString (readonly)

Returns the message id.

Returns:

  • (String)

    the message id


49
# File 'lib/redd/models/private_message.rb', line 49

property :id

#nameString (readonly)

Returns the message fullname.

Returns:

  • (String)

    the message fullname


94
# File 'lib/redd/models/private_message.rb', line 94

property :name

#new?Boolean (readonly)

Returns whether the message is new.

Returns:

  • (Boolean)

    whether the message is new


77
# File 'lib/redd/models/private_message.rb', line 77

property :new?, from: :new

#num_commentsInteger (readonly)

Returns huh?.

Returns:

  • (Integer)

    huh?


65
# File 'lib/redd/models/private_message.rb', line 65

property :num_comments

#parent_idString? (readonly)

Returns the parent id.

Returns:

  • (String, nil)

    the parent id


69
# File 'lib/redd/models/private_message.rb', line 69

property :parent_id

#repliesListing<PrivateMessage> (readonly)

Returns:


45
# File 'lib/redd/models/private_message.rb', line 45

property :replies, with: ->(l) { Listing.new(client, l[:data]) if l.is_a?(Hash) }

#subjectString (readonly)

Returns the message subject.

Returns:

  • (String)

    the message subject


53
# File 'lib/redd/models/private_message.rb', line 53

property :subject

#subredditSubreddit? (readonly)

Returns the subreddit that sent the message.

Returns:

  • (Subreddit, nil)

    the subreddit that sent the message


41
# File 'lib/redd/models/private_message.rb', line 41

property :subreddit, with: ->(s) { Subreddit.new(client, display_name: s) if s }

#subreddit_name_prefixedString (readonly)

Returns the subreddit name, prefixed with “r/”.

Returns:

  • (String)

    the subreddit name, prefixed with “r/”


73
# File 'lib/redd/models/private_message.rb', line 73

property :subreddit_name_prefixed

#was_comment?Boolean (readonly)

Returns:

  • (Boolean)

57
# File 'lib/redd/models/private_message.rb', line 57

property :was_comment?, from: :was_comment

Instance Method Details

#deleteObject

Delete the message from the user's inbox.


17
18
19
# File 'lib/redd/models/private_message.rb', line 17

def delete
  client.post('/api/del_msg', id: read_attribute(:name))
end

#mute_authorObject

Mute the author of the message.


22
23
24
# File 'lib/redd/models/private_message.rb', line 22

def mute_author
  client.post('/api/mute_message_author', id: read_attribute(:name))
end

#unmute_authorObject

Unmute the author of the message.


27
28
29
# File 'lib/redd/models/private_message.rb', line 27

def unmute_author
  client.post('/api/unmute_message_author', id: read_attribute(:name))
end