Class: Pik::ScriptFile
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(file) {|_self| ... } ⇒ ScriptFile
7
8
9
10
11
|
# File 'lib/pik/scripts/script_file.rb', line 7
def initialize(file) @file = Pathname.new(file.to_s + extname)
@file_data = []
yield self if block_given?
end
|
Instance Attribute Details
#file_data ⇒ Object
Returns the value of attribute file_data.
5
6
7
|
# File 'lib/pik/scripts/script_file.rb', line 5
def file_data
@file_data
end
|
#file_name ⇒ Object
Returns the value of attribute file_name.
5
6
7
|
# File 'lib/pik/scripts/script_file.rb', line 5
def file_name
@file_name
end
|
Returns the value of attribute ruby_dir.
5
6
7
|
# File 'lib/pik/scripts/script_file.rb', line 5
def ruby_dir
@ruby_dir
end
|
Instance Method Details
39
40
41
|
# File 'lib/pik/scripts/script_file.rb', line 39
def << (cmd)
@file_data << cmd
end
|
#echo(string = '.') ⇒ Object
21
22
23
24
25
|
# File 'lib/pik/scripts/script_file.rb', line 21
def echo(string='.')
string = ' ' + string unless string == '.'
@file_data << "ECHO#{string}"
self
end
|
17
18
19
|
# File 'lib/pik/scripts/script_file.rb', line 17
def extname
raise
end
|
13
14
15
|
# File 'lib/pik/scripts/script_file.rb', line 13
def path
@file
end
|
#remove_line(re) ⇒ Object
27
28
29
|
# File 'lib/pik/scripts/script_file.rb', line 27
def remove_line(re)
@file_data.reject!{ |i| i =~ re }
end
|
31
32
33
|
# File 'lib/pik/scripts/script_file.rb', line 31
def to_s
@file_data.join("\n")
end
|
35
36
37
|
# File 'lib/pik/scripts/script_file.rb', line 35
def write
File.open(@file, 'w+'){|f| f.puts self.to_s }
end
|