Module: Brcobranca::Boleto::Template::Rghost2

Extended by:
Rghost2
Includes:
RGhost
Included in:
Rghost2
Defined in:
lib/brcobranca/boleto/template/rghost2.rb

Overview

Templates para usar com Rghost

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Stream

Cria o métodos dinâmicos (to_pdf, to_gif e etc) com todos os fomátos válidos.

Examples:

@boleto.to_pdf #=> boleto gerado no formato pdf

Returns:

  • (Stream)

See Also:

  • Recebe os mesmos parâmetros do Rghost#modelo_generico.


55
56
57
58
59
60
61
62
# File 'lib/brcobranca/boleto/template/rghost2.rb', line 55

def method_missing(m, *args)
  method = m.to_s
  if method.start_with?('to_')
    modelo_generico(self, (args.first || {}).merge!(formato: method[3..-1]))
  else
    super
  end
end

Instance Method Details

#lote(boletos, options = {}) ⇒ Stream

Gera o boleto em usando o formato desejado [:pdf, :jpg, :tif, :png, :ps, :laserjet, … etc]

Returns:

  • (Stream)

See Also:



45
46
47
# File 'lib/brcobranca/boleto/template/rghost2.rb', line 45

def lote(boletos, options = {})
  modelo_generico_multipage(boletos, options)
end

#to(formato, options = {}) ⇒ Stream

Gera o boleto em usando o formato desejado [:pdf, :jpg, :tif, :png, :ps, :laserjet, … etc]

Returns:

  • (Stream)

See Also:



36
37
38
# File 'lib/brcobranca/boleto/template/rghost2.rb', line 36

def to(formato, options = {})
  modelo_generico(self, options.merge!(formato: formato))
end