Class: RGhost::Function

Inherits:
PsObject show all
Defined in:
lib/rghost/function.rb

Overview

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

Direct Known Subclasses

Grid::StaticCallback, StaticDocumentCallback

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PsObject

#<<, #call, #graphic_scope, #raw, #set, #to_s

Constructor Details

#initialize(name, body_function = nil, &block) ⇒ Function

Returns a new instance of Function.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rghost/function.rb', line 14

def initialize(name,body_function=nil,&block)
  if block
    #super(&block)
    super(&block)
      
  else
      
    super("")
  end  
  @name=name
  @body_function=body_function

end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/rghost/function.rb', line 12

def name
  @name
end

Instance Method Details

#psObject



32
33
34
35
36
# File 'lib/rghost/function.rb', line 32

def ps
  @body_function||=super
    
  "\n/#{@name}{\n#{@body_function}\n} bind def \n"
end

#use_template(function_name) ⇒ Object



28
29
30
31
# File 'lib/rghost/function.rb', line 28

def use_template(function_name)
  call "_#{function_name}"
 
end