Class: CopyStatement
- Inherits:
-
Object
- Object
- CopyStatement
- Defined in:
- lib/copy_statement.rb
Overview
Encapsulate the details of a COBOL COPY statement.
Instance Method Summary collapse
- #copybook_name ⇒ Object
- #has_period? ⇒ Boolean
- #has_replacing? ⇒ Boolean
-
#initialize(line) ⇒ CopyStatement
constructor
Parse out the key elements of a COPY statement.
- #new_value ⇒ Object
- #old_value ⇒ Object
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_name ⇒ Object
20 21 22 |
# File 'lib/copy_statement.rb', line 20 def copybook_name @copybook_name end |
#has_period? ⇒ Boolean
24 25 26 |
# File 'lib/copy_statement.rb', line 24 def has_period? @has_period end |
#has_replacing? ⇒ Boolean
28 29 30 |
# File 'lib/copy_statement.rb', line 28 def has_replacing? @has_replacing end |
#new_value ⇒ Object
36 37 38 |
# File 'lib/copy_statement.rb', line 36 def new_value @new_value end |
#old_value ⇒ Object
32 33 34 |
# File 'lib/copy_statement.rb', line 32 def old_value @old_value end |