Class: PdfTemplator::Formatter
- Inherits:
-
Object
- Object
- PdfTemplator::Formatter
- Defined in:
- lib/pdf_templator/formatter.rb
Instance Method Summary collapse
-
#apply(type, args = {}) ⇒ string
Format content.
-
#initialize(content) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(content) ⇒ Formatter
Returns a new instance of Formatter.
7 8 9 |
# File 'lib/pdf_templator/formatter.rb', line 7 def initialize(content) @content = content end |
Instance Method Details
#apply(type, args = {}) ⇒ string
Format content
16 17 18 19 20 21 22 |
# File 'lib/pdf_templator/formatter.rb', line 16 def apply(type, args = {}) # Symbolize keys args = args.map { |k, v| [k.to_sym, v] }.to_h I18n.locale = args[:locale] || :en klass = PdfTemplator.string_to_type_class(type) klass.new(@content, args).call end |