Class: RubyCord::User::Activity

Inherits:
DiscordModel show all
Defined in:
lib/rubycord/user/activity.rb

Overview

Represents an activity of a user.

Defined Under Namespace

Classes: Asset, Button, Flag, Party, Secrets, Timestamps

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

#application_idRubyCord::Snowflake (readonly)

Returns The application id of the activity.

Returns:



18
19
20
# File 'lib/rubycord/user/activity.rb', line 18

def application_id
  @application_id
end

#assetsRubyCord::User::Activity::Asset? (readonly)

Returns:



30
31
32
# File 'lib/rubycord/user/activity.rb', line 30

def assets
  @assets
end

#buttonsArray<RubyCord::User::Activity::Button>? (readonly)

Returns:



36
37
38
# File 'lib/rubycord/user/activity.rb', line 36

def buttons
  @buttons
end

#created_atTime (readonly) Also known as: started_at

Returns The time the activity was created.

Returns:

  • (Time)

    The time the activity was created.



13
14
15
# File 'lib/rubycord/user/activity.rb', line 13

def created_at
  @created_at
end

#detailsString (readonly)

Returns The details of the activity.

Returns:

  • (String)

    The details of the activity.



20
21
22
# File 'lib/rubycord/user/activity.rb', line 20

def details
  @details
end

#emojiRubyCord::Emoji (readonly)

Returns The emoji of the activity.

Returns:



24
25
26
# File 'lib/rubycord/user/activity.rb', line 24

def emoji
  @emoji
end

#flagsRubyCord::User::Activity::Flag (readonly)

Returns The flags of the activity.

Returns:



38
39
40
# File 'lib/rubycord/user/activity.rb', line 38

def flags
  @flags
end

#instanceRubyCord::Guild::StageChannel::StageInstance? (readonly)

Returns:



33
34
35
# File 'lib/rubycord/user/activity.rb', line 33

def instance
  @instance
end

#nameString (readonly)

Returns The name of the activity.

Returns:

  • (String)

    The name of the activity.



7
8
9
# File 'lib/rubycord/user/activity.rb', line 7

def name
  @name
end

#partyRubyCord::User::Activity::Party? (readonly)

Returns:



27
28
29
# File 'lib/rubycord/user/activity.rb', line 27

def party
  @party
end

#stateString (readonly)

Returns The state of party.

Returns:

  • (String)

    The state of party.



22
23
24
# File 'lib/rubycord/user/activity.rb', line 22

def state
  @state
end

#timestampsRubyCord::User::Activity::Timestamps (readonly)

Returns The timestamps of the activity.

Returns:



16
17
18
# File 'lib/rubycord/user/activity.rb', line 16

def timestamps
  @timestamps
end

#type:game, ... (readonly)

Returns The type of the activity.

Returns:

  • (:game, :streaming, :listening, :watching, :custom, :competing)

    The type of the activity.



9
10
11
# File 'lib/rubycord/user/activity.rb', line 9

def type
  @type
end

#urlString (readonly)

Returns The url of the activity.

Returns:

  • (String)

    The url of the activity.



11
12
13
# File 'lib/rubycord/user/activity.rb', line 11

def url
  @url
end

Instance Method Details

#to_sString

Convert the activity to a string.

Returns:

  • (String)

    The string representation of the activity.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/rubycord/user/activity.rb', line 87

def to_s
  case @type
  when :game
    "Playing #{@name}"
  when :streaming
    "Streaming #{@details}"
  when :listening
    "Listening to #{@name}"
  when :watching
    "Watching #{@name}"
  when :custom
    "#{@emoji} #{@state}"
  when :competing
    "Competing in #{@name}"
  else
    raise "Unknown activity type: #{@type}"
  end
end