class Expander
Command-line driver for COBOL copy expander utility.
Public Class Methods
new(argv=ARGV)
click to toggle source
# File lib/expander.rb, line 11 def initialize(argv=ARGV) @argv = argv end
Public Instance Methods
close_expanded_file()
click to toggle source
# File lib/expander.rb, line 62 def close_expanded_file @expanded_file.close end
close_source_file()
click to toggle source
# File lib/expander.rb, line 54 def close_source_file @source_file.close end
eof?()
click to toggle source
# File lib/expander.rb, line 42 def eof? @eof end
open_expanded_file()
click to toggle source
# File lib/expander.rb, line 58 def open_expanded_file @expanded_file = File.open("#{output_dir('.')}/#{expanded_file('TEMP.CBL')}", 'w') end
open_source_file()
click to toggle source
# File lib/expander.rb, line 46 def open_source_file if @argv == nil || @argv[0] == nil abort 'Usage: expander name-of-cobol-source-file' end @source_file = File.open("#{source_dir}/#{@argv[0]}", 'r') @eof = false end
process_source()
click to toggle source
# File lib/expander.rb, line 24 def process_source init begin output_line = process read_line write_from output_line.to_s unless output_line == nil end while @eof == false end
read_line()
click to toggle source
# File lib/expander.rb, line 32 def read_line line = ('%-80.80s' % @source_file.readline.chomp) @eof = @source_file.eof? line end
run()
click to toggle source
# File lib/expander.rb, line 15 def run load_config @argv open_source_file open_expanded_file process_source close_expanded_file close_source_file end
write_from(line)
click to toggle source
# File lib/expander.rb, line 38 def write_from line @expanded_file.write ('%-80.80s' % line.chomp) + "\n" end