Class: HonorCodes::Generator
- Inherits:
-
Object
- Object
- HonorCodes::Generator
- Defined in:
- lib/honor_codes/core.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#template_path ⇒ Object
Returns the value of attribute template_path.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(template_path, filename) ⇒ Generator
constructor
A new instance of Generator.
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
#filename ⇒ Object
Returns the value of attribute filename.
21 22 23 |
# File 'lib/honor_codes/core.rb', line 21 def filename @filename end |
#template_path ⇒ Object
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
#generate ⇒ Object
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 |