Class: Mo2tex::Calendar
- Inherits:
-
Object
- Object
- Mo2tex::Calendar
- Defined in:
- lib/mo2tex/calendar.rb
Defined Under Namespace
Classes: UnknownEvent
Instance Attribute Summary collapse
-
#day_schedule_templates ⇒ Object
readonly
Returns the value of attribute day_schedule_templates.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#exclude ⇒ Object
readonly
Returns the value of attribute exclude.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #create_icalendar(school) ⇒ Object
- #create_pic_schedule(school) ⇒ Object
-
#initialize(config) ⇒ Calendar
constructor
A new instance of Calendar.
- #to_file(school, fname = nil) ⇒ Object
Constructor Details
#initialize(config) ⇒ Calendar
Returns a new instance of Calendar.
15 16 17 18 19 20 21 |
# File 'lib/mo2tex/calendar.rb', line 15 def initialize(config) @filename = config['file'] @start_date = DateTime.parse(config['start_date'].to_s) @end_date = DateTime.parse(config['end_date'].to_s) @exclude = ExclusionManager.new(config['exclude'], self.start_date, self.end_date) @day_schedule_templates = parse_day_schedule_templates(config['day_schedule']) end |
Instance Attribute Details
#day_schedule_templates ⇒ Object (readonly)
Returns the value of attribute day_schedule_templates.
11 12 13 |
# File 'lib/mo2tex/calendar.rb', line 11 def day_schedule_templates @day_schedule_templates end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
11 12 13 |
# File 'lib/mo2tex/calendar.rb', line 11 def end_date @end_date end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
11 12 13 |
# File 'lib/mo2tex/calendar.rb', line 11 def events @events end |
#exclude ⇒ Object (readonly)
Returns the value of attribute exclude.
11 12 13 |
# File 'lib/mo2tex/calendar.rb', line 11 def exclude @exclude end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
11 12 13 |
# File 'lib/mo2tex/calendar.rb', line 11 def filename @filename end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
11 12 13 |
# File 'lib/mo2tex/calendar.rb', line 11 def start_date @start_date end |
Instance Method Details
#create_icalendar(school) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mo2tex/calendar.rb', line 23 def create_icalendar(school) ical = Icalendar::Calendar.new school.courses.each do |title, course| course.events.each do |ev| ev.to_ical(ical) end end return ical.publish end |
#create_pic_schedule(school) ⇒ Object
35 36 37 |
# File 'lib/mo2tex/calendar.rb', line 35 def create_pic_schedule(school) pic = Pic.new(school) end |
#to_file(school, fname = nil) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/mo2tex/calendar.rb', line 39 def to_file(school, fname = nil) fname ||= self.filename ical = self.create_icalendar(school) File.open(fname, 'w') { |fh| fh.puts(ical.to_ical) } return fname end |