Class: Rem2ics::Converter
- Inherits:
-
Object
- Object
- Rem2ics::Converter
- Defined in:
- lib/rem2ics/converter.rb
Overview
Reminder files in, one iCalendar out.
The conversion is a fold over what Remind gives: every reminder in every file becomes an event, in file order, in one VCALENDAR. What it skips is what a calendar has nowhere to put -- RUN reminders execute shell commands, CAL and PS reminders draw on a PostScript calendar, and none of them is an appointment.
"Today" is pinned for the whole conversion, because it is what a relative
trigger is relative to: REM Mon starts on a different Monday depending
on when it is asked. Pinning it makes the same file convert to the same
calendar every time, which is what makes the output diffable and the
conversion testable.
Constant Summary collapse
- PRODID =
"-//rem2ics//NONSGML rem2ics #{VERSION}//EN"
Instance Attribute Summary collapse
-
#horizon ⇒ Object
readonly
Returns the value of attribute horizon.
-
#organizer ⇒ Object
readonly
Returns the value of attribute organizer.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
-
.local_address ⇒ Object
id -nu@uname -n, which is what the Perl this descends from used, and is as good a guess at an organizer as a reminder file can support.
Instance Method Summary collapse
- #call(paths, today: Date.today) ⇒ Object
-
#initialize(session: Remind::Session.new, horizon: Recurrence::DEFAULT_HORIZON, organizer: nil, warnings: $stderr) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(session: Remind::Session.new, horizon: Recurrence::DEFAULT_HORIZON, organizer: nil, warnings: $stderr) ⇒ Converter
Returns a new instance of Converter.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rem2ics/converter.rb', line 30 def initialize( session: Remind::Session.new, horizon: Recurrence::DEFAULT_HORIZON, organizer: nil, warnings: $stderr ) @session = session @horizon = horizon @organizer = organizer || self.class.local_address @warnings = warnings end |
Instance Attribute Details
#horizon ⇒ Object (readonly)
Returns the value of attribute horizon.
28 29 30 |
# File 'lib/rem2ics/converter.rb', line 28 def horizon @horizon end |
#organizer ⇒ Object (readonly)
Returns the value of attribute organizer.
28 29 30 |
# File 'lib/rem2ics/converter.rb', line 28 def organizer @organizer end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
28 29 30 |
# File 'lib/rem2ics/converter.rb', line 28 def session @session end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
28 29 30 |
# File 'lib/rem2ics/converter.rb', line 28 def warnings @warnings end |
Class Method Details
.local_address ⇒ Object
id -nu@uname -n, which is what the Perl this descends from used, and
is as good a guess at an organizer as a reminder file can support.
44 45 46 47 48 |
# File 'lib/rem2ics/converter.rb', line 44 def self.local_address login = Etc.getlogin || ENV.fetch("USER", "remind") "#{login}@#{Etc.uname.fetch(:nodename)}" end |
Instance Method Details
#call(paths, today: Date.today) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/rem2ics/converter.rb', line 50 def call(paths, today: Date.today) session.today = today calendar.tap do |ical| paths.each { |path| add_file(ical, path) } end end |