Sha256: c3dd2243a4d3253c2096ad87289def5cc2e7fb5eab2feb910ad16d51f39991ab

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

# Standard way to access information to be used in a list_of()
class DataAdaptor
  def initialize(source)
    @section = Toc.instance.section(source)
  end

  # column_selector is one of: :number, :date, :title, :homework
  COL_NAMES = { number: '#', date: 'lecture date', title: 'title',
                homework: 'homework', desc: 'description', cat: 'category', hwref: 'homework', lectref: 'topics', reading: 'reading' }

  def column_name(column_selector)
    COL_NAMES[column_selector]
  end

  def rows
    @section.each do |citem|
      yield citem
    end
  end

  def cell_value(citem, col_selector)
    case col_selector
    when :number
      citem.lecture_number
    when :date
      citem.lecture_date
    when :title
      citem.title
    when :url
      citem.identifier
    when :desc
      citem.desc
    when :due
      citem.due
    when :homework
      citem.homework
    when :assigned
      citem.assigned
    when :cat
      citem.cat
    when :start_date_time
      citem.schedule_start_date_time
    when :end_date_time
      citem.schedule_end_date_time
    when :full_desc
      desc = citem.desc || ''
      hw = citem.homework || ''
      desc + '. HW: ' + hw
    when :lectref
      citem.lectref
    when :hwref
      citem.hwref
    when :reading
      citem.reading
    when :order
      citem.order
    else
      'error!'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
coursegen-0.9.25 lib/coursegen/course/data/data_adaptor.rb
coursegen-0.9.24 lib/coursegen/course/data/data_adaptor.rb
coursegen-0.9.21 lib/coursegen/course/data/data_adaptor.rb
coursegen-0.9.20 lib/coursegen/course/data/data_adaptor.rb