Class: JAXB2Ruby::Template
- Inherits:
-
Object
- Object
- JAXB2Ruby::Template
- Defined in:
- lib/jaxb2ruby/template.rb
Overview
:nodoc:
Constant Summary collapse
- HEADING =
"#\n# Auto-generated by jaxb2ruby v<%= VERSION %> on <%= Time.now %>\n# https://github.com/sshaw/jaxb2ruby\n#\n"- PATHS =
Hash[ Dir[File.(__FILE__ + "/../../templates/*.erb")].map do |path| [File.basename(path, ".erb"), path]
- DEFAULT =
Instance Method Summary collapse
- #build(klass) ⇒ Object
-
#initialize(name = nil) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(name = nil) ⇒ Template
Returns a new instance of Template.
20 21 22 23 24 25 26 |
# File 'lib/jaxb2ruby/template.rb', line 20 def initialize(name = nil) # If it's not a named template assume it's a path path = PATHS[name] || name || DEFAULT @__erb = ERB.new(HEADING + File.read(path), nil, "<>%-") rescue => e raise Error, "cannot load class template: #{e}" end |
Instance Method Details
#build(klass) ⇒ Object
28 29 30 31 |
# File 'lib/jaxb2ruby/template.rb', line 28 def build(klass) @class = klass @__erb.result(binding) end |