Class: CoopAl::Item
- Inherits:
-
Object
- Object
- CoopAl::Item
- Defined in:
- lib/coop_al/item.rb
Overview
Item
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Instance Method Summary collapse
- #description_with_origin ⇒ Object
-
#initialize(count, description, encounter) ⇒ Item
constructor
A new instance of Item.
- #origin ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(count, description, encounter) ⇒ Item
Returns a new instance of Item.
8 9 10 11 12 |
# File 'lib/coop_al/item.rb', line 8 def initialize(count, description, encounter) @count = count @description = description @encounter = encounter end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/coop_al/item.rb', line 6 def description @description end |
Instance Method Details
#description_with_origin ⇒ Object
22 23 24 |
# File 'lib/coop_al/item.rb', line 22 def description_with_origin "#{self} (from #{origin})" end |
#origin ⇒ Object
26 27 28 |
# File 'lib/coop_al/item.rb', line 26 def origin @encounter.full_name end |
#to_s ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/coop_al/item.rb', line 14 def to_s if @count == 1 @description else "#{@description} (#{@count})" end end |