Class: Memerator::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/memerator/notification.rb

Overview

A notification

Instance Method Summary collapse

Instance Method Details

#idInteger

Returns the ID of this notification.

Returns:

  • (Integer)

    the ID of this notification


9
10
11
# File 'lib/memerator/notification.rb', line 9

def id
  @data['id']
end

#memeidString?

For meme ratings, the meme ID is returned, if you need it!

Returns:

  • (String, nil)

    the meme ID, if type == 0


45
46
47
48
49
# File 'lib/memerator/notification.rb', line 45

def memeid
  return nil if @data['meme'].nil?

  @data['meme']['memeid']
end

#messageString

Returns the notification, formatted.

Returns:

  • (String)

    the notification, formatted.


24
25
26
# File 'lib/memerator/notification.rb', line 24

def message
  @data['message']
end

#ratingInteger?

For meme ratings, the meme rating is returned, if you need it!

Returns:

  • (Integer, nil)

    the meme rating, if type == 0


53
54
55
56
57
# File 'lib/memerator/notification.rb', line 53

def rating
  return nil if @data['meme'].nil?

  @data['meme']['rating']
end

#rawString

Returns the raw message as it appears on Memerator.me.

Returns:

  • (String)

    the raw message as it appears on Memerator.me


29
30
31
# File 'lib/memerator/notification.rb', line 29

def raw
  @data['raw']
end

#senderUser

Returns the sender of this notification.

Returns:

  • (User)

    the sender of this notification.


14
15
16
# File 'lib/memerator/notification.rb', line 14

def sender
  Memerator::User.new(@data['sender'])
end

#timestampTime

Returns the time this was sent.

Returns:

  • (Time)

    the time this was sent


19
20
21
# File 'lib/memerator/notification.rb', line 19

def timestamp
  Time.parse(@data['timestamp'])
end

#typeInteger

The type is mostly used internally but is useful for clients implementing notification sorting. Type 0 is a meme rating notification Type 1 is a follow notification Type 2 is a notice. Type 3 is a report status update

Returns:

  • (Integer)

    the type of this message


39
40
41
# File 'lib/memerator/notification.rb', line 39

def type
  @data['type']
end