lib/simple_tasks_ruby/converters/week_converter.rb
def convert_lines_to_week
      possibleDaysTester = PossibleDaysTester.new
      @week = Week.new(@week_name)
      
      current_day = nil

      @lines.each do |line|
        begin
          if possibleDaysTester.is_day(line.data) 
            current_day = Day.new(line.data) 
            @week.add_day(current_day)
            next
          end

          return @week if self.class.is_end_of_week(line.data)
          
          # Skip lines which are found before any day is found - these are old, 
          # not significant lines
          if current_day == nil
            logger.info("Skipping line #{line}")
            next
          else
            # If not a day, and not the end of the week, then it can be a task.
            # But, tasks start only with the hyphen.
            next unless self.class.is_task(line.data)

            task_creator = TaskCreator.new(line.data, current_day.date)
            task = task_creator.create_task
            current_day.add_task(task)
          end
        
        rescue
          logger.error("Error for line #{line}")
          raise
        end
      end

      return @week
    end
# Returns week object (with days and actions in them) based on raw input
Returns week object (with days and actions in them) based on raw input
Returns week object ( with days and actions in them ) based on raw input
def convert_lines_to_week
      possibleDaysTester = PossibleDaysTester.new
      @week = Week.new(@week_name)
      current_day = nil
      @lines.each do |line|
        begin
          if possibleDaysTester.is_day(line.data) 
            current_day = Day.new(line.data) 
            @week.add_day(current_day)
            next
          end
          return @week if self.class.is_end_of_week(line.data)
          if current_day == nil
            logger.info("Skipping line #{line}")
            next
          else
            next unless self.class.is_task(line.data)
            task_creator = TaskCreator.new(line.data, current_day.date)
            task = task_creator.create_task
            current_day.add_task(task)
          end
        rescue
          logger.error("Error for line #{line}")
          raise
        end
      end
      return @week
    end
def convert_lines_to_week possibleDaysTester = PossibleDaysTester . new @week = Week . new ( @week_name ) current_day = nil @lines . each do | line | begin if possibleDaysTester . is_day ( line . data ) current_day = Day . new ( line . data ) @week . add_day ( current_day ) next end return @week if self . class . is_end_of_week ( line . data ) if current_day == nil logger . info ( "Skipping line #{line}" ) next else next unless self . class . is_task ( line . data ) task_creator = TaskCreator . new ( line . data , current_day . date ) task = task_creator . create_task current_day . add_task ( task ) end rescue logger . error ( "Error for line #{line}" ) raise end end return @week end
Returns week object (with days and actions in them) based on raw input
Returns week object ( with days and actions in them ) based on raw input
# Skip lines which are found before any day is found - these are old,  # not significant lines # If not a day, and not the end of the week, then it can be a task. # But, tasks start only with the hyphen.