Class: DataAdaptor
- Inherits:
-
Object
- Object
- DataAdaptor
- Defined in:
- lib/coursegen/course/data/data_adaptor.rb
Overview
Standard way to access information to be used in a list_of()
Constant Summary collapse
- COL_NAMES =
column_selector is one of: :number, :date, :title, :homework
{ number: '#', date: 'lecture date', title: 'title', homework: 'homework', desc: 'description', cat: 'category', hwref: 'homework', lectref: 'topics', reading: 'reading' }
Instance Method Summary collapse
- #cell_value(citem, col_selector) ⇒ Object
- #column_name(column_selector) ⇒ Object
-
#initialize(source) ⇒ DataAdaptor
constructor
A new instance of DataAdaptor.
- #rows ⇒ Object
Constructor Details
#initialize(source) ⇒ DataAdaptor
Returns a new instance of DataAdaptor.
3 4 5 |
# File 'lib/coursegen/course/data/data_adaptor.rb', line 3 def initialize(source) @section = Toc.instance.section(source) end |
Instance Method Details
#cell_value(citem, col_selector) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/coursegen/course/data/data_adaptor.rb', line 21 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 |
#column_name(column_selector) ⇒ Object
11 12 13 |
# File 'lib/coursegen/course/data/data_adaptor.rb', line 11 def column_name(column_selector) COL_NAMES[column_selector] end |
#rows ⇒ Object
15 16 17 18 19 |
# File 'lib/coursegen/course/data/data_adaptor.rb', line 15 def rows @section.each do |citem| yield citem end end |