4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/publisci/output.rb', line 4
def output(string, options={},append=false)
options[:type] = [:string] unless options[:type]
base = options[:file_base]
name = options[:file_name]
types = Array(options[:type])
if types.include? :print
puts string
end
if types.include? :file
raise "no file specified output" unless name
method = append ? 'a' : 'w'
open("#{base}#{name}", method) { |f| f.write str }
end
if types.include? :string
string
end
end
|