class Dmcli::SpellList

SpellList Stores a list of Spell objects

Attributes

spells[R]

Public Class Methods

new() click to toggle source
# File lib/dmcli/spell_list.rb, line 9
def initialize
  @spells = []
end

Public Instance Methods

add(spell) click to toggle source
# File lib/dmcli/spell_list.rb, line 13
def add(spell)
  @spells.push(spell)
end
list() click to toggle source
# File lib/dmcli/spell_list.rb, line 21
def list
  puts "#{"Name".ljust(35)} #{"Class".ljust(13)} #{"Lvl".ljust(4)} #{"Range".ljust(30)} #{"Duration".ljust(45)} Effect"
  puts "----------------------------------------------------------------------------------------------------------------------------------------------------------"
  @spells.each do |spell|
    puts spell.to_s
  end
end
sort() click to toggle source
# File lib/dmcli/spell_list.rb, line 17
def sort
  @spells.sort_by! { |spell| [spell.spell_level, spell.spell_class, spell.name] }
end