Class: PfrpgImport::SpellWriter

Inherits:
Object
  • Object
show all
Includes:
CaseHelpers
Defined in:
lib/pfrpg_import/spell_writer.rb

Instance Method Summary collapse

Methods included from CaseHelpers

#arrayify, #camelized_title, #underscored_title

Constructor Details

#initialize(spells, filename, path = './imported/') ⇒ SpellWriter



4
5
6
7
8
# File 'lib/pfrpg_import/spell_writer.rb', line 4

def initialize(spells, filename, path='./imported/')
  @spells = spells
  @filename = filename
  @path = path
end

Instance Method Details



23
24
25
26
27
28
29
# File 'lib/pfrpg_import/spell_writer.rb', line 23

def print_level_bonus
  "spells =\n  \#{@spells}\nspells[level-1]\n  eos\nend\n"


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pfrpg_import/spell_writer.rb', line 10

def print_spells
  filename = "#{@path}#{underscored_title(@filename)}_spells.rb"
  table = File.new(filename, "w")
  str = "class PfrpgTables::Tables::Spells::SpellsPerDay\n"
  str += "  def self.#{camelized_title(@filename)}(level)\n"
  str += print_level_bonus
  str += "  end\n"
  str += "end\n"
  table.puts str
  table.close
  puts "Wrote #{filename}"
end