class Markdo::IcsExporter
Public Class Methods
new(task_collection)
click to toggle source
# File lib/markdo/ics_exporter.rb, line 5 def initialize(task_collection) @task_collection = task_collection end
Public Instance Methods
to_ics()
click to toggle source
# File lib/markdo/ics_exporter.rb, line 9 def to_ics buf = [] buf << 'BEGIN:VCALENDAR' buf << 'VERSION:2.0' buf << 'CALSCALE:GREGORIAN' buf << 'METHOD:PUBLISH' buf << 'X-WR-CALNAME:Markdo Due Dates' buf << events.map { |event| event.to_ics } buf << 'END:VCALENDAR' buf. flatten. map { |line| "#{line}\n" }. join end
Private Instance Methods
clean(line)
click to toggle source
# File lib/markdo/ics_exporter.rb, line 43 def clean(line) line.sub(%r(@due\(.*\)\s), '') end
events()
click to toggle source
# File lib/markdo/ics_exporter.rb, line 28 def events @task_collection. with_attribute('due'). reject { |task| task.complete? }. map { |task| due_date = task.attributes['due'].date_value summary = clean(task.body) if due_date Event.new(due_date, due_date, summary) end }. compact end