Class: Mo2tex::Course
- Inherits:
-
Object
- Object
- Mo2tex::Course
- Includes:
- CourseHelper
- Defined in:
- lib/mo2tex/course.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dur ⇒ Object
readonly
Returns the value of attribute dur.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#excl_mgr ⇒ Object
readonly
Returns the value of attribute excl_mgr.
-
#freq ⇒ Object
readonly
Returns the value of attribute freq.
-
#hours ⇒ Object
readonly
Returns the value of attribute hours.
-
#hours_done ⇒ Object
readonly
Returns the value of attribute hours_done.
-
#online ⇒ Object
readonly
Returns the value of attribute online.
-
#real_type ⇒ Object
readonly
Returns the value of attribute real_type.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#students ⇒ Object
readonly
Returns the value of attribute students.
-
#students_fc ⇒ Object
readonly
Returns the value of attribute students_fc.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
-
#wday ⇒ Object
readonly
Returns the value of attribute wday.
-
#when ⇒ Object
readonly
Returns the value of attribute when.
-
#where ⇒ Object
readonly
Returns the value of attribute where.
Class Method Summary collapse
Instance Method Summary collapse
- #academic_hours ⇒ Object
- #all_students ⇒ Object
- #course_dur_in_seconds ⇒ Object
- #generate(&block) ⇒ Object
- #hours_done_per_lesson(dts, dte) ⇒ Object
-
#initialize(title, desc, exmgr) ⇒ Course
constructor
A new instance of Course.
- #lesson_dur_in_seconds ⇒ Object
- #num_students ⇒ Object
- #number_of_lessons ⇒ Object
- #total_hours ⇒ Object
Methods included from CourseHelper
Constructor Details
#initialize(title, desc, exmgr) ⇒ Course
Returns a new instance of Course.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mo2tex/course.rb', line 15 def initialize(title, desc, exmgr) @warnings = {} @hours_done = 0 @excl_mgr = exmgr self.excl_mgr << desc['exclude'] if desc.has_key?('exclude') @title = normalize_title(title) @hours = desc['ore'] @type = desc['tipologia'] @real_type = desc['tip_effettiva'] @students = desc['studenti'] @students_fc = desc['studenti_fc'] @start = DateTime.parse(desc['inizio'].to_s) @freq = parse_frequency(desc['frequenza']) @wday = desc['giorno'] @dur = parse_dur(desc['durata_lezione']) # beware! YAML converts in seconds! @when = parse_dur(desc['orario']) # beware! YAML converts in seconds! @where = 'aula ' + desc['aula'] @online = desc['online'] @events = generate_events end |
Instance Attribute Details
#dur ⇒ Object (readonly)
Returns the value of attribute dur.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def dur @dur end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def events @events end |
#excl_mgr ⇒ Object (readonly)
Returns the value of attribute excl_mgr.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def excl_mgr @excl_mgr end |
#freq ⇒ Object (readonly)
Returns the value of attribute freq.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def freq @freq end |
#hours ⇒ Object (readonly)
Returns the value of attribute hours.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def hours @hours end |
#hours_done ⇒ Object (readonly)
Returns the value of attribute hours_done.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def hours_done @hours_done end |
#online ⇒ Object (readonly)
Returns the value of attribute online.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def online @online end |
#real_type ⇒ Object (readonly)
Returns the value of attribute real_type.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def real_type @real_type end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def start @start end |
#students ⇒ Object (readonly)
Returns the value of attribute students.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def students @students end |
#students_fc ⇒ Object (readonly)
Returns the value of attribute students_fc.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def students_fc @students_fc end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def type @type end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def warnings @warnings end |
#wday ⇒ Object (readonly)
Returns the value of attribute wday.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def wday @wday end |
#when ⇒ Object (readonly)
Returns the value of attribute when.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def when @when end |
#where ⇒ Object (readonly)
Returns the value of attribute where.
11 12 13 |
# File 'lib/mo2tex/course.rb', line 11 def where @where end |
Class Method Details
.create(title, desc, exm) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mo2tex/course.rb', line 60 def create(title, desc, exm) result = nil case desc['tip_effettiva'] when 'collettiva' result = CollectiveCourse.new(title, desc, exm) when 'individuale' result = IndividualCourse.new(title, desc, exm) else raise UnknownCourseType, "Unknown type #{desc['tipologia']}" end return result end |
Instance Method Details
#academic_hours ⇒ Object
84 85 86 |
# File 'lib/mo2tex/course.rb', line 84 def academic_hours return self.total_hours end |
#all_students ⇒ Object
88 89 90 |
# File 'lib/mo2tex/course.rb', line 88 def all_students return self.students + ' ' + self.students_fc end |
#course_dur_in_seconds ⇒ Object
45 46 47 |
# File 'lib/mo2tex/course.rb', line 45 def course_dur_in_seconds return self.academic_hours * 3600 end |
#generate(&block) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/mo2tex/course.rb', line 36 def generate(&block) result = '' self.events.each do |ev| result += yield(self.title, self.number_of_lessons, ev) end return result end |
#hours_done_per_lesson(dts, dte) ⇒ Object
92 93 94 |
# File 'lib/mo2tex/course.rb', line 92 def hours_done_per_lesson(dts, dte) raise PureVirtualMethodCalled, 'Course#hours_done_per_lesson' end |
#lesson_dur_in_seconds ⇒ Object
49 50 51 |
# File 'lib/mo2tex/course.rb', line 49 def lesson_dur_in_seconds return ((self.dur * 24)*3600).round.to_i end |
#num_students ⇒ Object
75 76 77 78 |
# File 'lib/mo2tex/course.rb', line 75 def num_students split_studs = self.students.split(/, */) return split_studs.size end |
#number_of_lessons ⇒ Object
53 54 55 56 |
# File 'lib/mo2tex/course.rb', line 53 def number_of_lessons result = (self.course_dur_in_seconds.to_f / self.lesson_dur_in_seconds.to_f).round.to_i return result end |
#total_hours ⇒ Object
80 81 82 |
# File 'lib/mo2tex/course.rb', line 80 def total_hours raise PureVirtualMethodCalled, 'Course#total_hours' end |