Class: Goby::Item
- Inherits:
-
Object
- Object
- Goby::Item
- Defined in:
- lib/goby/item/item.rb
Overview
Can be used by an Entity in order to trigger anything specified. Placed into the Entity’s inventory.
Constant Summary collapse
- DEFAULT_USE_TEXT =
Default text when the Item doesn’t do anything.
"Nothing happens.\n\n"
Instance Attribute Summary collapse
-
#consumable ⇒ Object
Returns the value of attribute consumable.
-
#disposable ⇒ Object
Returns the value of attribute disposable.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
Instance Method Summary collapse
- #==(rhs) ⇒ Object
-
#initialize(name: "Item", price: 0, consumable: true, disposable: true) ⇒ Item
constructor
A new instance of Item.
-
#to_s ⇒ String
The name of the Item.
-
#use(user, entity) ⇒ Object
The function that executes when one uses the item.
Constructor Details
#initialize(name: "Item", price: 0, consumable: true, disposable: true) ⇒ Item
Returns a new instance of Item.
14 15 16 17 18 19 |
# File 'lib/goby/item/item.rb', line 14 def initialize(name: "Item", price: 0, consumable: true, disposable: true) @name = name @price = price @consumable = consumable @disposable = disposable end |
Instance Attribute Details
#consumable ⇒ Object
Returns the value of attribute consumable.
39 40 41 |
# File 'lib/goby/item/item.rb', line 39 def consumable @consumable end |
#disposable ⇒ Object
Returns the value of attribute disposable.
39 40 41 |
# File 'lib/goby/item/item.rb', line 39 def disposable @disposable end |
#name ⇒ Object
Returns the value of attribute name.
39 40 41 |
# File 'lib/goby/item/item.rb', line 39 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
39 40 41 |
# File 'lib/goby/item/item.rb', line 39 def price @price end |
Instance Method Details
#==(rhs) ⇒ Object
30 31 32 |
# File 'lib/goby/item/item.rb', line 30 def ==(rhs) return @name.casecmp(rhs.name).zero? end |
#to_s ⇒ String
Returns the name of the Item.
35 36 37 |
# File 'lib/goby/item/item.rb', line 35 def to_s @name end |
#use(user, entity) ⇒ Object
The function that executes when one uses the item.
25 26 27 |
# File 'lib/goby/item/item.rb', line 25 def use(user, entity) print DEFAULT_USE_TEXT end |