1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
require "rghost/ps_object"
# Creates postscript internal function. Example
# f=RGhost::Function.new :foo do
# set Show.new("A Test")
# end
# In ps stack will be
# /foo (A Test) show def
class RGhost::Function < RGhost::PsObject
attr_reader :name
def initialize(name, body_function = nil, &block)
if block
super(&block)
else
super("")
end
@name = name
@body_function = body_function
end
def use_template(function_name)
call "_#{function_name}"
end
def ps
@body_function ||= super
"\n/#{@name}{\n#{@body_function}\n} bind def \n"
end
end
|