Class: CoopAl::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/coop_al/item.rb

Overview

Item

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject (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_originObject



22
23
24
# File 'lib/coop_al/item.rb', line 22

def description_with_origin
  "#{self} (from #{origin})"
end

#originObject



26
27
28
# File 'lib/coop_al/item.rb', line 26

def origin
  @encounter.full_name
end

#to_sObject



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