Module: ChiliPDF::TokenManager
Constant Summary collapse
- MAPPINGS =
{:current_page => { :replacement_object => "[page]", :description => "The current page of the PDF document."}, :total_pages => { :replacement_object => '[topage]', :description => "The total number of pages in the PDF document."}, :datestamp => { :replacement_object => lambda {Time.now.strftime('%d-%b-%Y')}, :description => "The current date in the format of DD-MON-YYYY'"}, :current_quarter => { :replacement_object => lambda {calculate_quarter.to_s}, :description => "The current fiscal quarter (assuming Jan-Mar is thefirst quarter). Example output: '1'."}, :current_year => { :replacement_object => lambda {Time.now.strftime('%Y')}, :description => "The current year in YYYY-format"}}
Instance Method Summary collapse
Instance Method Details
#add_token_definition ⇒ Object
27 28 29 |
# File 'lib/chili_pdf/token_manager.rb', line 27 def add_token_definition raw_tokens.merge!(yield) end |
#apply_tokens_to(string) ⇒ Object
31 32 33 |
# File 'lib/chili_pdf/token_manager.rb', line 31 def apply_tokens_to(string) tokens.inject(string.dup) {|modified, token| modified = token.apply_to modified} end |
#tokens ⇒ Object
21 22 23 24 25 |
# File 'lib/chili_pdf/token_manager.rb', line 21 def tokens raw_tokens.map {|matcher, | StringToken.new(matcher, [:replacement_object], [:description]) } end |