Class: Wlog::TemplateEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/wlog/domain/template_engine.rb

Overview

Author:

  • Simon Symeonidis

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue_sep, log_entry_sep, issues, invoice_id) ⇒ TemplateEngine

These can either be atomic elements, or arrays of two. In the former, they just join entries by adding the separator. The latter makes the two a prefix, and postfix.

Parameters:

  • issue_sep

    is what to separate issues with

  • log_entry_sep

    is what to separate log entries with



17
18
19
20
# File 'lib/wlog/domain/template_engine.rb', line 17

def initialize(issue_sep, log_entry_sep, issues, invoice_id)
  @issue_sep, @log_entry_sep, @issues, @invoice_id = \
    issue_sep, log_entry_sep, issues, invoice_id
end

Instance Attribute Details

#issue_sepObject

What to separate issues with



28
29
30
# File 'lib/wlog/domain/template_engine.rb', line 28

def issue_sep
  @issue_sep
end

#issuesObject

An issue list



34
35
36
# File 'lib/wlog/domain/template_engine.rb', line 34

def issues
  @issues
end

#log_entry_sepObject

What to separate log entries with



31
32
33
# File 'lib/wlog/domain/template_engine.rb', line 31

def log_entry_sep
  @log_entry_sep
end

Instance Method Details

#generate(filename) ⇒ Object



22
23
24
25
# File 'lib/wlog/domain/template_engine.rb', line 22

def generate(filename)
  contents = File.open(filename).read
  contens.gsub(InvoiceId, @invoice_id)
end