Module: Brcobranca::Boleto::Template::Rghost

Extended by:
Rghost
Includes:
RGhost
Included in:
Rghost
Defined in:
lib/brcobranca/boleto/template/rghost.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.

Returns:

  • (Stream)

See Also:

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


59
60
61
62
63
64
65
66
# File 'lib/brcobranca/boleto/template/rghost.rb', line 59

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

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

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

Returns:

  • (Stream)

See Also:



43
44
45
46
47
48
49
50
51
# File 'lib/brcobranca/boleto/template/rghost.rb', line 43

def imprimir_lista(boletos, options={})
  
  # Adicionando :formato apenas para garantir a compatibilidade com o codigo da versao 3
  options = Brcobranca::Config::OPCOES.merge({
    :formato => Brcobranca::Config::OPCOES[:tipo]
  }).merge(options)
  
  modelo_generico_multipage(boletos, options)
end

#to(formato = Brcobranca::Config::OPCOES[:tipo], options = {}) ⇒ Stream

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

Returns:

  • (Stream)

See Also:



30
31
32
33
34
35
36
# File 'lib/brcobranca/boleto/template/rghost.rb', line 30

def to(formato = Brcobranca::Config::OPCOES[:tipo], options={})
  
  # Adicionando :formato apenas para garantir a compatibilidade com o codigo da versao 3
  options = Brcobranca::Config::OPCOES.merge(options)
  
  modelo_generico(self, options.merge!({:formato => formato}))
end