Class: Cheque::Copy

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Prawn::View
Defined in:
lib/cheque/copy.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Copy

Returns a new instance of Copy.



33
34
35
36
37
38
39
40
41
42
# File 'lib/cheque/copy.rb', line 33

def initialize(params)
  I18n.locale = params[:locale] || DEFAULT_LOCALE

  default_params.merge(params).each do |param, value|
    send("#{param}=", value)
  end

  self.errors = {}
  I18n.locale = locale
end

Instance Method Details

#dataObject



44
45
46
47
48
49
# File 'lib/cheque/copy.rb', line 44

def data
  return unless valid?

  prepare
  render
end

#fileObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/cheque/copy.rb', line 51

def file
  return unless valid?

  @file ||= lambda do
    prepare
    save_as(path)

    path
  end.call
end