Class: HonorCodes::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/honor_codes/core.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_path, filename) ⇒ Generator

Returns a new instance of Generator.



23
24
25
26
# File 'lib/honor_codes/core.rb', line 23

def initialize(template_path, filename)
  self.template_path = template_path
  self.filename = filename
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



21
22
23
# File 'lib/honor_codes/core.rb', line 21

def filename
  @filename
end

#template_pathObject

Returns the value of attribute template_path.



21
22
23
# File 'lib/honor_codes/core.rb', line 21

def template_path
  @template_path
end

Instance Method Details

#generateObject



28
29
30
31
32
33
34
35
# File 'lib/honor_codes/core.rb', line 28

def generate
  template = Pathname.new(template_path)
  license = template.dirname.join(filename)
  license.open('w') do |file|
    file << Base64.encode64(template.read)
  end
  license.to_s
end