Class: RGhost::Callback
- Includes:
- RubyToPs
- Defined in:
- lib/rghost/callback.rb
Overview
Callbacks are custom code blocks defined inside of Document. All callbacks received implicitly a instance of PsFacade can be creates any PsObject. The callbacks’s execution depend of the algorithims predefined in Postscript core library. There are two kind of callbacks, Statics and Dynamics callbacks. A Static callback there aren’t parameters to control of the inclusion and exception on current scope, usually applied for events which happen one time, for example after_document_create, “after document create” always will execute one time for each document. Otherwise Dynamic callbacks there is control of scope using conditional :only or :except, this is only difference in relation the static callbacks. The parameters of a Dynamic callbak must be one integer or one array of integer. Example: For all pages except page 3
doc.before_page_create :except => 3 do |b|
# do something
end
For just 2 and 4 pages
doc.before_page_create :only => [2,4] do |b|
# do something
end
The most of callbacks are defined in facades such as DocumentCallbackFacade and Grid::CallbackFacade
Direct Known Subclasses
Instance Attribute Summary collapse
-
#except ⇒ Object
Returns the value of attribute except.
-
#name ⇒ Object
Returns the value of attribute name.
-
#only ⇒ Object
Returns the value of attribute only.
Instance Method Summary collapse
-
#initialize(name, options = {}, &block) ⇒ Callback
constructor
A new instance of Callback.
- #ps ⇒ Object
Methods included from RubyToPs
#array_to_stack, #hash_to_array, #pack_string, #ps_escape, #string_eval, #to_array, #to_bool, #to_string, #to_string_array
Methods inherited from PsObject
#<<, #call, #graphic_scope, #raw, #set, #to_s
Constructor Details
Instance Attribute Details
#except ⇒ Object
Returns the value of attribute except.
24 25 26 |
# File 'lib/rghost/callback.rb', line 24 def except @except end |
#name ⇒ Object
Returns the value of attribute name.
24 25 26 |
# File 'lib/rghost/callback.rb', line 24 def name @name end |
#only ⇒ Object
Returns the value of attribute only.
24 25 26 |
# File 'lib/rghost/callback.rb', line 24 def only @only end |
Instance Method Details
#ps ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/rghost/callback.rb', line 36 def ps @only=num_to_array(@options[:only]) @except=num_to_array(@options[:except]) "\n/#{@name} 3 dict def #{@name} begin \n/proc { #{super} } bind def \n/except #{to_array(@except)} def \n/only #{to_array(@only)} def \nend " end |