def create_class_weeks(week_data)
      week_span_regex   = /([\d]{2}-[\d]{2})/
      week_start_regex  = /^[0-9]{2}/
      week_end_regex    = /[0-9]{2}$/
      week_single_regex = /[\d]{2}/

      class_weeks = Array.new

      week_data.scan(@@WEEKS_REGEX).each do |weekspan|

        # if it's a 28-39 week span
        if weekspan =~ week_span_regex
          start  = week_start_regex.match(weekspan)[0].to_i
          finish = week_end_regex.match(weekspan)[0].to_i

          while start <= finish
            class_weeks << start
            start += 1
          end

        # some single week (30, 31, 32 etc) support
        elsif weekspan =~ week_single_regex
          class_weeks << week_single_regex.match(weekspan)[0].to_i
        end
      end

      class_weeks
    end
def create_class_weeks(week_data)
      week_span_regex   = /([\d]{2}-[\d]{2})/
      week_start_regex  = /^[0-9]{2}/
      week_end_regex    = /[0-9]{2}$/
      week_single_regex = /[\d]{2}/

      class_weeks = Array.new

      week_data.scan(@@WEEKS_REGEX).each do |weekspan|

        # if it's a 28-39 week span
        if weekspan =~ week_span_regex
          start  = week_start_regex.match(weekspan)[0].to_i
          finish = week_end_regex.match(weekspan)[0].to_i

          while start <= finish
            class_weeks << start
            start += 1
          end

        # some single week (30, 31, 32 etc) support
        elsif weekspan =~ week_single_regex
          class_weeks << week_single_regex.match(weekspan)[0].to_i
        end
      end

      class_weeks
    end
def create_class_weeks ( week_data ) week_span_regex = / \d \d / week_start_regex = / / week_end_regex = / / week_single_regex = / \d / class_weeks = Array . new week_data . scan ( @@WEEKS_REGEX ) . each do | weekspan | # if it's a 28-39 week span if weekspan =~ week_span_regex start = week_start_regex . match ( weekspan ) [ 0 ] . to_i finish = week_end_regex . match ( weekspan ) [ 0 ] . to_i while start <= finish class_weeks << start start += 1 end # some single week (30, 31, 32 etc) support elsif weekspan =~ week_single_regex class_weeks << week_single_regex . match ( weekspan ) [ 0 ] . to_i end end class_weeks end
Create the week range array for the given week string
Create the week range array for the given week string