Class: DDAPI::Item

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

Overview

Represents a DRPG guild item.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, app) ⇒ Integer

attr_accessor :id



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/dd-api/classes.rb', line 229

def initialize(data, app)
  @data = data
  @name = data['name']
  @level = data['level']
  @description = data['desc']
  @type = data['type']
  @image = API.image_url(data['image'])
  #@id = data['id']
  @prefix = data['prefix']
  @prefix = data['plural']
  @sellable = data['sellable']
  @tradeable = data['tradeable']
  @sell_price = data['sell'] == -1 ? nil : data['sell']
  @cost = data['cost'] == -1 ? nil : data['cost']
  @app = app
end

Instance Attribute Details

#descriptionString Also known as: desc

Returns The description of the item.

Returns:

  • (String)

    The description of the item.



157
158
159
# File 'lib/dd-api/classes.rb', line 157

def description
  @description
end

#imageString

Returns The image URL to the item.

Returns:

  • (String)

    The image URL to the item.



161
162
163
# File 'lib/dd-api/classes.rb', line 161

def image
  @image
end

#levelInteger Also known as: lvl

Returns The level of the item.

Returns:

  • (Integer)

    The level of the item.



164
165
166
# File 'lib/dd-api/classes.rb', line 164

def level
  @level
end

#nameString

Returns The name of the item.

Returns:

  • (String)

    The name of the item.



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

def name
  @name
end

#pluralString

Returns The plural name of the item.

Returns:

  • (String)

    The plural name of the item.



151
152
153
# File 'lib/dd-api/classes.rb', line 151

def plural
  @plural
end

#prefixString

Returns The prefix name of the item.

Returns:

  • (String)

    The prefix name of the item.



148
149
150
# File 'lib/dd-api/classes.rb', line 148

def prefix
  @prefix
end

#sell_priceInteger?

Returns The cost of the item. nil if not buyable.

Returns:

  • (Integer, nil)

    The cost of the item. nil if not buyable.



145
146
147
# File 'lib/dd-api/classes.rb', line 145

def sell_price
  @sell_price
end

#sellabletrue, false

Returns Whether the item is sellable.

Returns:

  • (true, false)

    Whether the item is sellable.



171
172
173
# File 'lib/dd-api/classes.rb', line 171

def sellable
  @sellable
end

#tradeabletrue, false

Returns Whether the item is tradeable.

Returns:

  • (true, false)

    Whether the item is tradeable.



177
178
179
# File 'lib/dd-api/classes.rb', line 177

def tradeable
  @tradeable
end

#typeString

Returns The type of the item.

Returns:

  • (String)

    The type of the item.



154
155
156
# File 'lib/dd-api/classes.rb', line 154

def type
  @type
end

Instance Method Details

#inspectObject

The inspect method is overwritten to give more useful output



197
198
199
# File 'lib/dd-api/classes.rb', line 197

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