Class: PfrpgCore::SpellBooks

Inherits:
Object
  • Object
show all
Defined in:
lib/pfrpg_core/spell_books.rb

Defined Under Namespace

Classes: InvalidClassException, InvalidSpellException, SpellNotFoundException, TooLowAttributeException, TooManySpellsException

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(character) ⇒ SpellBooks

Returns a new instance of SpellBooks.



12
13
14
15
16
17
18
19
20
21
# File 'lib/pfrpg_core/spell_books.rb', line 12

def initialize(character)
  l = character.latest_levels
  @wizard = character.spells_per_level('Wizard', l)
  @cleric = character.spells_per_level('Cleric', l)
  @druid = character.spells_per_level('Druid', l)
  @paladin = character.spells_per_level('Paladin', l)
  @ranger = character.spells_per_level('Ranger', l)
  @bard = character.spells_per_level('Bard', l)
  @sorcerer = character.known_sorcerer_spells
end

Instance Attribute Details

#bardObject (readonly)

Returns the value of attribute bard.



10
11
12
# File 'lib/pfrpg_core/spell_books.rb', line 10

def bard
  @bard
end

#clericObject (readonly)

Returns the value of attribute cleric.



10
11
12
# File 'lib/pfrpg_core/spell_books.rb', line 10

def cleric
  @cleric
end

#druidObject (readonly)

Returns the value of attribute druid.



10
11
12
# File 'lib/pfrpg_core/spell_books.rb', line 10

def druid
  @druid
end

#paladinObject (readonly)

Returns the value of attribute paladin.



10
11
12
# File 'lib/pfrpg_core/spell_books.rb', line 10

def paladin
  @paladin
end

#rangerObject (readonly)

Returns the value of attribute ranger.



10
11
12
# File 'lib/pfrpg_core/spell_books.rb', line 10

def ranger
  @ranger
end

#sorcererObject (readonly)

Returns the value of attribute sorcerer.



10
11
12
# File 'lib/pfrpg_core/spell_books.rb', line 10

def sorcerer
  @sorcerer
end

#wizardObject (readonly)

Returns the value of attribute wizard.



10
11
12
# File 'lib/pfrpg_core/spell_books.rb', line 10

def wizard
  @wizard
end

Instance Method Details

#as_json(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pfrpg_core/spell_books.rb', line 23

def as_json(options={})
  {
      :sorcerer_spells  => @sorcerer,
      :Cleric    => @cleric,
      :Wizard    => @wizard,
      :Druid     => @druid,
      :Paladin   => @paladin,
      :Ranger    => @ranger,
      :Bard      => @bard
  }
end