lib/prawn/document.rb in prawn-2.3.0 vs lib/prawn/document.rb in prawn-2.4.0

- old
+ new

@@ -96,10 +96,11 @@ @extensions ||= [] end # @private def self.inherited(base) + super extensions.each { |e| base.extensions << e } end # @group Stable Attributes @@ -568,31 +569,33 @@ # def number_pages(string, options = {}) opts = options.dup start_count_at = opts.delete(:start_count_at).to_i - page_filter = if opts.key?(:page_filter) - opts.delete(:page_filter) - else - :all - end + page_filter = + if opts.key?(:page_filter) + opts.delete(:page_filter) + else + :all + end total_pages = opts.delete(:total_pages) txtcolor = opts.delete(:color) # An explicit height so that we can draw page numbers in the margins opts[:height] = 50 unless opts.key?(:height) start_count = false pseudopage = 0 (1..page_count).each do |p| unless start_count - pseudopage = case start_count_at - when 0 - 1 - else - start_count_at.to_i - end + pseudopage = + case start_count_at + when 0 + 1 + else + start_count_at.to_i + end end if page_match?(page_filter, p) go_to_page(p) # have to use fill_color here otherwise text reverts back to default # fill color @@ -666,13 +669,13 @@ def mask(*fields) # Stores the current state of the named attributes, executes the block, # and then restores the original values after the block has executed. # -- I will remove the nodoc if/when this feature is a little less hacky stored = {} - fields.each { |f| stored[f] = send(f) } + fields.each { |f| stored[f] = public_send(f) } yield - fields.each { |f| send("#{f}=", stored[f]) } + fields.each { |f| public_send("#{f}=", stored[f]) } end # @group Extension API def initialize_first_page(options) @@ -735,11 +738,13 @@ sides = %i[top right bottom left] margin = Array(options[:margin]) # Treat :margin as CSS shorthand with 1-4 values. positions = { - 4 => [0, 1, 2, 3], 3 => [0, 1, 2, 1], - 2 => [0, 1, 0, 1], 1 => [0, 0, 0, 0], + 4 => [0, 1, 2, 3], + 3 => [0, 1, 2, 1], + 2 => [0, 1, 0, 1], + 1 => [0, 0, 0, 0], 0 => [] }[margin.length] sides.zip(positions).each do |side, pos| new_margin = options[:"#{side}_margin"] || (margin[pos] if pos)