def create_class(class_element)
      begin
        tt_class = Tableau::Class.new(@day, @time)
        data = class_element.xpath('table/tr/td//text()')
        raise "Misformed cell for #{module_id}" if data.count < 4
      rescue Exception => e
        p "EXCEPTION: #{e.message}", "Data Parsed:", data
        return nil
      end

      # If the weeks are in the 2nd index, it's a core timetable
      if @@WEEKS_REGEX.match(data[1].text())
        tt_class.code = data[0].text().match(/^[A-Za-z0-9\-]+/).to_s
        tt_class.type = data[0].text().gsub(tt_class.code, '').gsub('/', '')

        tt_class.weeks    = create_class_weeks(data[1].text())
        tt_class.location = data[2].text()
        tt_class.name     = data[3].text()
      else # this is a module timetable, laid out differently
        if data[0].to_s != ""
          tt_class.code = data[0].text().match(/^[A-Za-z0-9\-]+/).to_s
          tt_class.type = data[0].text().gsub(tt_class.code, '').gsub('/', '')
        end

        tt_class.location  = data[1].text()
        tt_class.name      = data[2].text()
        tt_class.weeks     = create_class_weeks(data[3].text())
      end

      # Same attribute on both timetables, DRY'd here
      tt_class.tutor = data[4] ? data[4].text() : nil

      if intervals = class_element.attribute('colspan').value
        tt_class.intervals = intervals.to_i
      end

      tt_class
    end
def create_class(class_element)
      begin
        tt_class = Tableau::Class.new(@day, @time)
        data = class_element.xpath('table/tr/td//text()')
        raise "Misformed cell for #{module_id}" if data.count < 4
      rescue Exception => e
        p "EXCEPTION: #{e.message}", "Data Parsed:", data
        return nil
      end

      # If the weeks are in the 2nd index, it's a core timetable
      if @@WEEKS_REGEX.match(data[1].text())
        tt_class.code = data[0].text().match(/^[A-Za-z0-9\-]+/).to_s
        tt_class.type = data[0].text().gsub(tt_class.code, '').gsub('/', '')

        tt_class.weeks    = create_class_weeks(data[1].text())
        tt_class.location = data[2].text()
        tt_class.name     = data[3].text()
      else # this is a module timetable, laid out differently
        if data[0].to_s != ""
          tt_class.code = data[0].text().match(/^[A-Za-z0-9\-]+/).to_s
          tt_class.type = data[0].text().gsub(tt_class.code, '').gsub('/', '')
        end

        tt_class.location  = data[1].text()
        tt_class.name      = data[2].text()
        tt_class.weeks     = create_class_weeks(data[3].text())
      end

      # Same attribute on both timetables, DRY'd here
      tt_class.tutor = data[4] ? data[4].text() : nil

      if intervals = class_element.attribute('colspan').value
        tt_class.intervals = intervals.to_i
      end

      tt_class
    end
Create a Class from the given data element