Class: Amy::Generator
- Inherits:
-
Object
- Object
- Amy::Generator
- Defined in:
- lib/amy/generate.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
Instance Method Summary collapse
- #do(template, object) ⇒ Object
-
#initialize(base_dir = "doc/") ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(base_dir = "doc/") ⇒ Generator
Returns a new instance of Generator.
9 10 11 |
# File 'lib/amy/generate.rb', line 9 def initialize(base_dir="doc/") @base_dir = base_dir end |
Instance Attribute Details
#base_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
7 8 9 |
# File 'lib/amy/generate.rb', line 7 def base_dir @base_dir end |
Instance Method Details
#do(template, object) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/amy/generate.rb', line 13 def do(template, object) Dir.mkdir(@base_dir) if (not File.exist?(@base_dir) or not File.directory?( @base_dir )) ehtml = ERB.new(IO.read(template)) output = ehtml.result(object.get_binding) File.open("#{@base_dir}#{object.path}", 'w') do |f| f.write(output) end end |