Class: Jksinatra::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/jksinatra/template.rb

Overview

Class for generate file

Instance Method Summary collapse

Constructor Details

#initialize(project_name, options, file_name) ⇒ Template

Returns a new instance of Template.



5
6
7
8
9
# File 'lib/jksinatra/template.rb', line 5

def initialize(project_name, options, file_name)
  @project_name = project_name
  @options = options
  @file_name = file_name
end

Instance Method Details

#generateObject



11
12
13
14
15
16
17
# File 'lib/jksinatra/template.rb', line 11

def generate
  template_path = File.join Jksinatra.templates, "root/#{@file_name}"
  template = File.read template_path
  File.open("#{@project_name}/#{@file_name[0..-5]}", 'a+') do |file|
    file.puts ERB.new(template).result(binding)
  end
end