Class: MotionGradle::Template
- Inherits:
-
Object
- Object
- MotionGradle::Template
- Defined in:
- lib/motion_gradle/template.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
Instance Method Summary collapse
-
#initialize(name) ⇒ Template
constructor
A new instance of Template.
- #write(locals = {}) ⇒ Object
Constructor Details
#initialize(name) ⇒ Template
Returns a new instance of Template.
5 6 7 8 |
# File 'lib/motion_gradle/template.rb', line 5 def initialize(name) template_path = File.("../templates/#{name}.erb", __FILE__) @template = ERB.new(File.new(template_path).read) end |
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
3 4 5 |
# File 'lib/motion_gradle/template.rb', line 3 def destination @destination end |
Instance Method Details
#write(locals = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/motion_gradle/template.rb', line 10 def write(locals = {}) File.open(self.destination, 'w') do |io| struct = OpenStruct.new(locals) io.puts(@template.result(struct.instance_eval { binding })) end end |