Class: Cpr::ClassGenerator
- Inherits:
-
Object
- Object
- Cpr::ClassGenerator
- Defined in:
- lib/cpr/class_generator.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(prefix, filename) ⇒ ClassGenerator
constructor
A new instance of ClassGenerator.
- #rows ⇒ Object
Constructor Details
#initialize(prefix, filename) ⇒ ClassGenerator
Returns a new instance of ClassGenerator.
69 70 71 72 |
# File 'lib/cpr/class_generator.rb', line 69 def initialize(prefix, filename) @prefix = prefix @filename = filename end |
Instance Method Details
#generate ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/cpr/class_generator.rb', line 74 def generate rows.each do |row| filename = "lib/cpr/#{@prefix}/#{row.name}.rb" File.open(filename, 'w') do |file| file << row.class_def("Cpr::#{@prefix.capitalize}", row.name) end end end |
#rows ⇒ Object
83 84 85 86 87 88 |
# File 'lib/cpr/class_generator.rb', line 83 def rows doc = Nokogiri::XML.parse(File.read(@filename)) (doc / "//Table").map do |table| RowSpec.parse_from_table(table) end end |