Module: Caracal::Core::PageNumbers
- Included in:
- Document
- Defined in:
- lib/caracal/core/page_numbers.rb
Overview
This module encapsulates all the functionality related to setting the document’s page number behavior.
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/caracal/core/page_numbers.rb', line 12 def self.included(base) base.class_eval do #------------------------------------------------------------- # Configuration #------------------------------------------------------------- # constants const_set(:DEFAULT_PAGE_NUMBER_ALIGN, :center) # accessors attr_reader :page_number_show attr_reader :page_number_align #------------------------------------------------------------- # Public Methods #------------------------------------------------------------- # This method controls whether and how page numbers are displayed # on the document. # def page_numbers(*args, &block) = Caracal::Utilities.(args) .merge!({ show: !!args.first }) unless args.first.nil? # careful: falsey value model = Caracal::Core::Models::PageNumberModel.new(, &block) if model.valid? @page_number_show = model.page_number_show @page_number_align = model.page_number_align else raise Caracal::Errors::InvalidModelError, 'page_numbers :align parameter must be :left, :center, or :right' end end end end |