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.



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/dd-api/classes.rb', line 209

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.



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

def description
  @description
end

#imageString

Returns The image URL to the item.

Returns:

  • (String)

    The image URL to the item.



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

def image
  @image
end

#levelInteger

Returns The level of the item.

Returns:

  • (Integer)

    The level of the item.



195
196
197
# File 'lib/dd-api/classes.rb', line 195

def level
  @level
end

#nameString

Returns The name of the item.

Returns:

  • (String)

    The name of the item.



173
174
175
# File 'lib/dd-api/classes.rb', line 173

def name
  @name
end

#pluralString

Returns The plural name of the item.

Returns:

  • (String)

    The plural name of the item.



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

def plural
  @plural
end

#prefixString

Returns The prefix name of the item.

Returns:

  • (String)

    The prefix name of the item.



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

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.



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

def sell_price
  @sell_price
end

#sellabletrue, false

Returns Whether the item is sellable.

Returns:

  • (true, false)

    Whether the item is sellable.



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

def sellable
  @sellable
end

#tradeabletrue, false

Returns Whether the item is tradeable.

Returns:

  • (true, false)

    Whether the item is tradeable.



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

def tradeable
  @tradeable
end

#typeString

Returns The type of the item.

Returns:

  • (String)

    The type of the item.



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

def type
  @type
end

Instance Method Details

#inspectObject

The inspect method is overwritten to give more useful output



227
228
229
# File 'lib/dd-api/classes.rb', line 227

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