Class: CopyStatement

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

Overview

Encapsulate the details of a COBOL COPY statement.

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ CopyStatement

Parse out the key elements of a COPY statement.



9
10
11
12
13
14
15
16
17
18
# File 'lib/copy_statement.rb', line 9

def initialize line
  tokens = line.gsub(/\s+/, ' ').split
  last = tokens.length-1
  @has_period = tokens[last].match(/\.$/) == nil ? false : true
  tokens[last] = tokens[last].gsub(/\./, '') 
  @copybook_name = tokens[1] 
  @has_replacing = tokens.length > 2 && tokens[2].downcase == 'replacing' ? true : false
  @old_value = strip_equals_signs(tokens[3]) if has_replacing?
  @new_value = strip_equals_signs(tokens[5]) if has_replacing?
end

Instance Method Details

#copybook_nameObject



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

def copybook_name
  @copybook_name
end

#has_period?Boolean

Returns:

  • (Boolean)


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

def has_period?
  @has_period
end

#has_replacing?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/copy_statement.rb', line 28

def has_replacing?
  @has_replacing
end

#new_valueObject



36
37
38
# File 'lib/copy_statement.rb', line 36

def new_value
  @new_value
end

#old_valueObject



32
33
34
# File 'lib/copy_statement.rb', line 32

def old_value
  @old_value
end