Class: JAXB2Ruby::Template
- Inherits:
-
Object
- Object
- JAXB2Ruby::Template
- Defined in:
- lib/jaxb2ruby/template.rb
Overview
:nodoc:
Constant Summary collapse
- HEADING =
<<HEAD # # Auto-generated by jaxb2ruby https://github.com/sshaw/jaxb2ruby # HEAD
- PATHS =
Hash[ Dir[File.expand_path(__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.
19 20 21 22 23 24 25 |
# File 'lib/jaxb2ruby/template.rb', line 19 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
27 28 29 30 |
# File 'lib/jaxb2ruby/template.rb', line 27 def build(klass) @class = klass @__erb.result(binding) end |