Class: ConvertDfhmdf
- Inherits:
-
Object
show all
- Includes:
- Dfhmdf
- Defined in:
- lib/convert_dfhmdf.rb
Constant Summary
Constants included
from Dfhmdf
Dfhmdf::VERSION
Instance Method Summary
collapse
Methods included from Dfhmdf
#clear, #dfhmdf?, #field_label, #field_length, #parse_operands, #parse_tokens, #te3270_text_field, #tokenize_line, #x_coordinate, #y_coordinate
Instance Method Details
#close_file ⇒ Object
62
63
64
|
# File 'lib/convert_dfhmdf.rb', line 62
def close_file
@source_file.close
end
|
#ingest_macro ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/convert_dfhmdf.rb', line 21
def ingest_macro
macro_end = false
@macro_source = ''
current_line = read_line
begin
if current_line == nil || current_line.length < 72 || current_line[71] == ' '
macro_end = true
end
@macro_source << squish(current_line)
current_line = read_line unless macro_end
end while macro_end == false
@macro_source
end
|
#macro_source ⇒ Object
44
45
46
|
# File 'lib/convert_dfhmdf.rb', line 44
def macro_source
@macro_source
end
|
#open_file ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/convert_dfhmdf.rb', line 54
def open_file
if ARGV[0] == nil
abort 'Usage: ruby make_fields.rb inputfilename'
end
@source_file = File.open(ARGV[0], 'r')
@eof = false
end
|
#process_macro(dfhmdf_macro) ⇒ Object
17
18
19
|
# File 'lib/convert_dfhmdf.rb', line 17
def process_macro dfhmdf_macro
parse_tokens tokenize_line dfhmdf_macro
end
|
#read_line ⇒ Object
48
49
50
51
52
|
# File 'lib/convert_dfhmdf.rb', line 48
def read_line
line = @source_file.readline
@eof = @source_file.eof?
line
end
|
#run ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/convert_dfhmdf.rb', line 6
def run
open_file
begin
clear
ingest_macro
process_macro @macro_source
puts te3270_text_field if dfhmdf?
end while @eof == false
close_file
end
|
#squish(str) ⇒ Object
39
40
41
42
|
# File 'lib/convert_dfhmdf.rb', line 39
def squish str
str[71] = ' ' unless str.length < 72
str.split.join(' ')
end
|