From 806f73fe4e16db7b4c36e13d51c22ff0ac2850a2 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Thu, 8 Aug 2019 11:24:42 +0200 Subject: [PATCH] Sections in a separate class attribute. --- src/spec.cr | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/spec.cr b/src/spec.cr index 527be51..bf1cc34 100644 --- a/src/spec.cr +++ b/src/spec.cr @@ -76,11 +76,12 @@ class Specs end - property assignments : Hash(String, StringContainer | LongStringContainer | Array(Section) | ArrayContainer) + property assignments : Hash(String, StringContainer | LongStringContainer | ArrayContainer) + property sections : Array(Section) def initialize - @assignments = Hash(String, StringContainer | LongStringContainer | Array(Section) | ArrayContainer).new - @assignments["sections"] = Array(Section).new + @assignments = Hash(String, StringContainer | LongStringContainer | ArrayContainer).new + @sections = Array(Section).new end def parse_assignment (line : String) @@ -236,10 +237,7 @@ class Specs end end - sections = @assignments["sections"] - if sections.is_a?(Array(Section)) - sections.push section - end + sections.push section end def parse_lines(content : Array(String)) @@ -366,12 +364,12 @@ class Specs replace_string_obj v when ArrayContainer replace_array_obj v - when Array(Section) - v.each do |section| - replace_section_obj section - end end end + + sections.each do |section| + replace_section_obj section + end end