Class: PrinceMerge

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

Defined Under Namespace

Classes: Recipient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, output, template = nil) ⇒ PrinceMerge

Returns a new instance of PrinceMerge.



11
12
13
14
15
# File 'lib/prince_merge.rb', line 11

def initialize(input, output, template = nil)
  @input = input
  @output = output
  @template = File.expand_path(File.dirname(__FILE__) + "/../templates/#{template || 'standard_envelope.haml'}")
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



9
10
11
# File 'lib/prince_merge.rb', line 9

def input
  @input
end

#outputObject

Returns the value of attribute output.



9
10
11
# File 'lib/prince_merge.rb', line 9

def output
  @output
end

#templateObject

Returns the value of attribute template.



9
10
11
# File 'lib/prince_merge.rb', line 9

def template
  @template
end

Instance Method Details

#htmlObject



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

def html
  Haml::Engine.new(template).render(Object.new, :recipients => Recipient.load_from_csv(input))
end

#renderObject



25
26
27
# File 'lib/prince_merge.rb', line 25

def render
  Prince.new.html_to_file(html, output)
end