Class: Waddup::Source::AppleCalendar
- Inherits:
-
Waddup::Source
- Object
- Waddup::Source
- Waddup::Source::AppleCalendar
- Extended by:
- Extension::AppleScript, Extension::FileSystem
- Includes:
- Extension::AppleScript
- Defined in:
- lib/waddup/sources/apple_calendar.rb
Constant Summary collapse
- ALIAS =
'ical'
- ICON =
"\xF0\x9F\x93\x85 "
- EVENT_SCRIPT =
folder_of(__FILE__) + 'apple_calender/events.applescript'
Class Method Summary collapse
-
.usable? ⇒ Boolean
Requires AppleScript to be available.
Instance Method Summary collapse
-
#events(from, to) ⇒ Object
Aggregates calendar events.
Methods included from Extension::AppleScript
Methods included from Extension::System
Methods included from Extension::FileSystem
Methods inherited from Waddup::Source
Methods included from Registry
Class Method Details
.usable? ⇒ Boolean
Requires AppleScript to be available
36 37 38 |
# File 'lib/waddup/sources/apple_calendar.rb', line 36 def self.usable? applescript? end |
Instance Method Details
#events(from, to) ⇒ Object
Aggregates calendar events
Arguments:
:from (datetime)
:to (datetime)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/waddup/sources/apple_calendar.rb', line 20 def events(from, to) results = applescript EVENT_SCRIPT, as_ruby: true, args: [from.strftime('%d/%m/%Y %H:%M'), to.strftime('%d/%m/%Y %H:%M')] results.map do |result| Waddup::Event.new do |e| e.label = result[:summary] e.at = Time.parse(result[:start_date]) e.until = Time.parse(result[:end_date]) e.source = self end end end |