Class: DDAPI::Guild

Inherits:
Object
  • Object
show all
Defined in:
lib/dd-api/classes.rb

Overview

Represents a DRPG guild.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, app) ⇒ Guild

Returns a new instance of Guild.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/dd-api/classes.rb', line 143

def initialize(data, app)
  @data = data
  gdata = data['guild']
  @name = data['name']
  @open = data['open']
  @level = gdata['level']
  @description = gdata['desc']
  @gold = gdata['gold']
  @kills = @data['slain']
  @deaths = @data['deaths']
  @icon = HTMLEntities.new.decode(gdata['icon'])
  @icons = gdata['icons'].map {|icon| HTMLEntities.new.decode(icon) }
  @id = data['id']
  @members = gdata['members']
  @level_requirement = gdata['levelreq']
  @max = gdata['max']
  @owner = @app.user(gdata['owner'])
  @role = gdata['role'].empty? ? nil : gdata['role']
  @channel = gdata['channel'].empty? ? nil : gdata['channel']
  @app = app
end

Instance Attribute Details

#channelString?

Returns The Discord Channel ID of the guild. nil if there is no channel.

Returns:

  • (String, nil)

    The Discord Channel ID of the guild. nil if there is no channel.



141
142
143
# File 'lib/dd-api/classes.rb', line 141

def channel
  @channel
end

#deathsInteger Also known as: frags

Returns The combined deaths by the guild members.

Returns:

  • (Integer)

    The combined deaths by the guild members.



112
113
114
# File 'lib/dd-api/classes.rb', line 112

def deaths
  @deaths
end

#descriptionString Also known as: desc

Returns The description of the guild.

Returns:

  • (String)

    The description of the guild.



102
103
104
# File 'lib/dd-api/classes.rb', line 102

def description
  @description
end

#goldInteger

Returns The amount gold in the guild.

Returns:

  • (Integer)

    The amount gold in the guild.



109
110
111
# File 'lib/dd-api/classes.rb', line 109

def gold
  @gold
end

#iconString

Returns The icon of the guild.

Returns:

  • (String)

    The icon of the guild.



132
133
134
# File 'lib/dd-api/classes.rb', line 132

def icon
  @icon
end

#iconsArray<String>

Returns Array of icons the guild has bought.

Returns:

  • (Array<String>)

    Array of icons the guild has bought.



135
136
137
# File 'lib/dd-api/classes.rb', line 135

def icons
  @icons
end

#idInteger

Returns The ID of the guild.

Returns:

  • (Integer)

    The ID of the guild.



126
127
128
# File 'lib/dd-api/classes.rb', line 126

def id
  @id
end

#killsInteger Also known as: slain

Returns The combined enemies slain by the guild members.

Returns:

  • (Integer)

    The combined enemies slain by the guild members.



116
117
118
# File 'lib/dd-api/classes.rb', line 116

def kills
  @kills
end

#levelInteger

Returns The level of the guild.

Returns:

  • (Integer)

    The level of the guild.



123
124
125
# File 'lib/dd-api/classes.rb', line 123

def level
  @level
end

#level_requirementInteger

Returns The level requirement of the guild.

Returns:

  • (Integer)

    The level requirement of the guild.



129
130
131
# File 'lib/dd-api/classes.rb', line 129

def level_requirement
  @level_requirement
end

#maxInteger

Returns The maximum amount of people that can be in the guild.

Returns:

  • (Integer)

    The maximum amount of people that can be in the guild.



120
121
122
# File 'lib/dd-api/classes.rb', line 120

def max
  @max
end

#nameString

Returns The name of the guild.

Returns:

  • (String)

    The name of the guild.



95
96
97
# File 'lib/dd-api/classes.rb', line 95

def name
  @name
end

#opentrue, false

Returns Whether the guild is open.

Returns:

  • (true, false)

    Whether the guild is open.



106
107
108
# File 'lib/dd-api/classes.rb', line 106

def open
  @open
end

#ownerUser Also known as: leader

Returns The user object of the guild owner.

Returns:

  • (User)

    The user object of the guild owner.



98
99
100
# File 'lib/dd-api/classes.rb', line 98

def owner
  @owner
end

#roleString?

Returns The Discord Role ID of the guild. nil if there is no role.

Returns:

  • (String, nil)

    The Discord Role ID of the guild. nil if there is no role.



138
139
140
# File 'lib/dd-api/classes.rb', line 138

def role
  @role
end

Instance Method Details

#inspectObject

The inspect method is overwritten to give more useful output



166
167
168
# File 'lib/dd-api/classes.rb', line 166

def inspect
  "#<DDAPI::Guild name=#{@name} id=#{@id} level=#{@level}>"
end