Class: Discorb::Application::Team::Member
- Inherits:
-
DiscordModel
- Object
- DiscordModel
- Discorb::Application::Team::Member
- Defined in:
- lib/discorb/application.rb
Overview
Represents a member of team.
Instance Attribute Summary collapse
-
#membership_state -> :invited, :accepted
(also: #state)
readonly
The member's membership state.
-
#permissions -> Array<Permissions>
readonly
The permissions of the member.
-
#team_id -> Snowflake
readonly
The ID of member's team.
-
#user -> Discorb::User
readonly
The user.
Instance Method Summary collapse
- #==(other) -> Object
- #accepted? -> Boolean
-
#initialize(client, team, data) -> Member
constructor
A new instance of Member.
- #inspect -> Object
- #owner? -> Boolean
- #pending? -> Boolean
Methods inherited from DiscordModel
Constructor Details
#initialize(client, team, data) -> Member
Returns a new instance of Member.
150 151 152 153 154 155 156 157 158 |
# File 'lib/discorb/application.rb', line 150 def initialize(client, team, data) @client = client @data = data @team = team @user = client.users[data[:user][:id]] || User.new(client, data[:user]) @team_id = Snowflake.new(data[:team_id]) @membership_state = self.class.membership_state[data[:membership_state]] @permissions = data[:permissions].map(&:to_sym) end |
Instance Attribute Details
#membership_state -> :invited, :accepted (readonly) Also known as: state
Returns The member's membership state.
132 133 134 |
# File 'lib/discorb/application.rb', line 132 def membership_state @membership_state end |
#permissions -> Array<Permissions> (readonly)
Note:
This always return :*
.
Returns The permissions of the member.
136 137 138 |
# File 'lib/discorb/application.rb', line 136 def @permissions end |
#team_id -> Snowflake (readonly)
Returns The ID of member's team.
130 131 132 |
# File 'lib/discorb/application.rb', line 130 def team_id @team_id end |
#user -> Discorb::User (readonly)
Returns The user.
128 129 130 |
# File 'lib/discorb/application.rb', line 128 def user @user end |
Instance Method Details
#==(other) -> Object
176 177 178 |
# File 'lib/discorb/application.rb', line 176 def ==(other) super || @user == other end |
#accepted? -> Boolean
164 165 166 |
# File 'lib/discorb/application.rb', line 164 def accepted? @membership_state == :accepted end |
#inspect -> Object
168 169 170 |
# File 'lib/discorb/application.rb', line 168 def inspect "#<#{self.class} id=#{@user.id}>" end |
#owner? -> Boolean
172 173 174 |
# File 'lib/discorb/application.rb', line 172 def owner? @team.owner_user_id == @user.id end |
#pending? -> Boolean
160 161 162 |
# File 'lib/discorb/application.rb', line 160 def pending? @membership_state == :invited end |