Class: Script

Inherits:
Object
  • Object
show all
Defined in:
lib/cchook/script.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, target) ⇒ Script

Returns a new instance of Script.



5
6
7
8
9
10
# File 'lib/cchook/script.rb', line 5

def initialize(name,target)
  @pre = []
  @post = []
  @name = name
  @target = target
end

Class Method Details

.add_prefix(array) ⇒ Object



24
25
26
# File 'lib/cchook/script.rb', line 24

def Script.add_prefix(array)
  array.map{|str| str = 'source ' << str}
end

.instance(name, target) ⇒ Object



20
21
22
# File 'lib/cchook/script.rb', line 20

def Script.instance(name,target)
  Script.new(name,target)
end

Instance Method Details

#add_post(script) ⇒ Object



16
17
18
# File 'lib/cchook/script.rb', line 16

def add_post(script)
  @post << script
end

#add_pre(script) ⇒ Object



12
13
14
# File 'lib/cchook/script.rb', line 12

def add_pre(script)
  @pre << script
end

#to_sObject



28
29
30
31
32
33
34
35
36
# File 'lib/cchook/script.rb', line 28

def to_s
  "function \#{@name}(){\n\#{Script.add_prefix(@pre).to_s}\n\#{@target}\n\#{Script.add_prefix(@post).to_s}\n}\n"
end