Class: DDAPI::Item

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

Overview

Represents a DRPG item.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, app) ⇒ Item

Returns a new instance of Item.



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/dd-api/classes.rb', line 214

def initialize(data, app)
  @data = data
  @name = data['name']
  @level = data['level']
  @description = data['desc']
  @type = data['type']
  @image = data['image'].nil? ? nil : 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.



193
194
195
# File 'lib/dd-api/classes.rb', line 193

def description
  @description
end

#imageString

Returns The image URL to the item. nil if there is no image.

Returns:

  • (String)

    The image URL to the item. nil if there is no image.



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

def image
  @image
end

#levelInteger

Returns The level of the item.

Returns:

  • (Integer)

    The level of the item.



200
201
202
# File 'lib/dd-api/classes.rb', line 200

def level
  @level
end

#nameString

Returns The name of the item.

Returns:

  • (String)

    The name of the item.



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

def name
  @name
end

#pluralString

Returns The plural name of the item.

Returns:

  • (String)

    The plural name of the item.



187
188
189
# File 'lib/dd-api/classes.rb', line 187

def plural
  @plural
end

#prefixString

Returns The prefix name of the item.

Returns:

  • (String)

    The prefix name of the item.



184
185
186
# File 'lib/dd-api/classes.rb', line 184

def prefix
  @prefix
end

#sell_priceInteger?

Returns The sell price of the item. nil if not sellable.

Returns:

  • (Integer, nil)

    The sell price of the item. nil if not sellable.



181
182
183
# File 'lib/dd-api/classes.rb', line 181

def sell_price
  @sell_price
end

#sellabletrue, false

Returns Whether the item is sellable.

Returns:

  • (true, false)

    Whether the item is sellable.



206
207
208
# File 'lib/dd-api/classes.rb', line 206

def sellable
  @sellable
end

#tradeabletrue, false

Returns Whether the item is tradeable.

Returns:

  • (true, false)

    Whether the item is tradeable.



212
213
214
# File 'lib/dd-api/classes.rb', line 212

def tradeable
  @tradeable
end

#typeString

Returns The type of the item.

Returns:

  • (String)

    The type of the item.



190
191
192
# File 'lib/dd-api/classes.rb', line 190

def type
  @type
end

Instance Method Details

#inspectObject

The inspect method is overwritten to give more useful output



232
233
234
# File 'lib/dd-api/classes.rb', line 232

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