Class: Prawn::Repeater
- Inherits:
-
Object
- Object
- Prawn::Repeater
- Defined in:
- lib/prawn/repeater.rb
Overview
:nodoc:
Experimental API collapse
- .count ⇒ Object
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Experimental API collapse
-
#initialize(document, page_filter, dynamic = false, &block) ⇒ Repeater
constructor
A new instance of Repeater.
- #match?(page_number) ⇒ Boolean
- #run(page_number) ⇒ Object
Constructor Details
#initialize(document, page_filter, dynamic = false, &block) ⇒ Repeater
Returns a new instance of Repeater.
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/prawn/repeater.rb', line 97 def initialize(document, page_filter, dynamic = false, &block) @document = document @page_filter = page_filter @dynamic = dynamic @stamp_name = "prawn_repeater(#{Repeater.count})" @document.create_stamp(@stamp_name, &block) unless dynamic @block = block if dynamic @graphic_state = document.state.page.graphic_state.dup Repeater.count += 1 end |
Class Attribute Details
.count ⇒ Object
90 91 92 |
# File 'lib/prawn/repeater.rb', line 90 def count @count ||= 0 end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
95 96 97 |
# File 'lib/prawn/repeater.rb', line 95 def name @name end |
Instance Method Details
#match?(page_number) ⇒ Boolean
109 110 111 |
# File 'lib/prawn/repeater.rb', line 109 def match?(page_number) @document.page_match?(@page_filter, page_number) end |
#run(page_number) ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/prawn/repeater.rb', line 113 def run(page_number) if !@dynamic @document.stamp(@stamp_name) if match?(page_number) elsif @block && match?(page_number) @document.save_graphics_state(@graphic_state) do @document.__send__(:freeze_stamp_graphics) @block.call end end end |