Class: Encounter
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#xp_value ⇒ Object
readonly
Returns the value of attribute xp_value.
Instance Method Summary collapse
-
#initialize(monster, amount, id = nil, xp_value = nil) ⇒ Encounter
constructor
A new instance of Encounter.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(monster, amount, id = nil, xp_value = nil) ⇒ Encounter
Returns a new instance of Encounter.
5 6 7 8 9 10 |
# File 'lib/encounters/encounter.rb', line 5 def initialize( monster, amount, id = nil, xp_value = nil ) @monster = monster @amount = amount @xp_value = xp_value ? xp_value : encounter_xp_value.to_i @id = id ? id : ( monster.key.to_s + '_' + amount.to_s ).to_sym end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/encounters/encounter.rb', line 3 def id @id end |
#xp_value ⇒ Object (readonly)
Returns the value of attribute xp_value.
3 4 5 |
# File 'lib/encounters/encounter.rb', line 3 def xp_value @xp_value end |
Instance Method Details
#to_hash ⇒ Object
16 17 18 |
# File 'lib/encounters/encounter.rb', line 16 def to_hash { id: @id, monster_key: @monster.key, amount: @amount, xp_value: @xp_value } end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/encounters/encounter.rb', line 12 def to_s "#{@amount} #{@monster.name}" end |