class

InventoryItem

Inherits JSON::Serializable < Reference < Object

Constructors

new(name : String, description : String, quantity : Int32 = 1)
Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source

Instance methods

description
Source
description=(description : String)
Source
name
Source
name=(name : String)
Source
quantity
Source
quantity=(quantity : Int32)
Source
same_type?(other_name : String) : Bool

Check if this is the same item type (for stacking)

Source
to_s(io : IO) : Nil

Format for display. We override to_s(io) (the method Crystal's string interpolation and IO#<< call) so inventory items render correctly anywhere they are interpolated — not as "#InventoryItem:0x...".

Source
to_s

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.

Source