Class: Cobplexity::Line
- Inherits:
-
Object
- Object
- Cobplexity::Line
- Defined in:
- lib/cobplexity/line.rb
Instance Method Summary collapse
- #area_a ⇒ Object
- #blank? ⇒ Boolean
- #branches ⇒ Object
- #code? ⇒ Boolean
- #comment? ⇒ Boolean
- #continuation? ⇒ Boolean
- #control ⇒ Object
- #copy_statement? ⇒ Boolean
-
#initialize(line) ⇒ Line
constructor
A new instance of Line.
- #paragraph? ⇒ Boolean
- #paragraph_name ⇒ Object
- #procedure_division? ⇒ Boolean
- #statement ⇒ Object
Constructor Details
#initialize(line) ⇒ Line
Returns a new instance of Line.
4 5 6 |
# File 'lib/cobplexity/line.rb', line 4 def initialize line @line = line.rstrip end |
Instance Method Details
#area_a ⇒ Object
36 37 38 |
# File 'lib/cobplexity/line.rb', line 36 def area_a self.statement[0..3].strip end |
#blank? ⇒ Boolean
10 11 12 |
# File 'lib/cobplexity/line.rb', line 10 def blank? self.statement.empty? end |
#branches ⇒ Object
22 23 24 25 26 |
# File 'lib/cobplexity/line.rb', line 22 def branches self.statement.split.count do |item| ['IF', 'ELSE', 'WHEN', 'WHILE', 'UNTIL', 'AND', 'OR'].include? item.upcase end end |
#code? ⇒ Boolean
7 8 9 |
# File 'lib/cobplexity/line.rb', line 7 def code? !self.blank? && !self.comment? && !self.continuation? && !self.paragraph? && !self.procedure_division? end |
#comment? ⇒ Boolean
16 17 18 |
# File 'lib/cobplexity/line.rb', line 16 def comment? self.control == '*' end |
#continuation? ⇒ Boolean
19 20 21 |
# File 'lib/cobplexity/line.rb', line 19 def continuation? self.control == '-' end |
#control ⇒ Object
39 40 41 |
# File 'lib/cobplexity/line.rb', line 39 def control @line.length > 6 ? @line[6] : ' ' end |
#copy_statement? ⇒ Boolean
30 31 32 |
# File 'lib/cobplexity/line.rb', line 30 def copy_statement? self.statement.match /COPY /i end |
#paragraph? ⇒ Boolean
13 14 15 |
# File 'lib/cobplexity/line.rb', line 13 def paragraph? !self.comment? && !self.continuation? && !self.area_a.empty? && !self.copy_statement? end |
#paragraph_name ⇒ Object
27 28 29 |
# File 'lib/cobplexity/line.rb', line 27 def paragraph_name self.statement.strip.delete '.' end |
#procedure_division? ⇒ Boolean
33 34 35 |
# File 'lib/cobplexity/line.rb', line 33 def procedure_division? self.statement.match /PROCEDURE DIVISION\./i end |
#statement ⇒ Object
42 43 44 |
# File 'lib/cobplexity/line.rb', line 42 def statement @line.length > 7 ? @line[7..71] : '' end |