Class: Tilia::VObject::FreeBusyGenerator
- Inherits:
-
Object
- Object
- Tilia::VObject::FreeBusyGenerator
- Defined in:
- lib/tilia/v_object/free_busy_generator.rb
Overview
This class helps with generating FREEBUSY reports based on existing sets of objects.
It only looks at VEVENT and VFREEBUSY objects from the sourcedata, and generates a single VFREEBUSY object.
VFREEBUSY components are described in RFC5545, The rules for what should go in a single freebusy report is taken from RFC4791, section 7.10.
Instance Attribute Summary collapse
-
#base_object ⇒ void
writeonly
Sets the VCALENDAR object.
-
#time_zone ⇒ void
writeonly
Sets the reference timezone for floating times.
Instance Method Summary collapse
-
#initialize(start = nil, ending = nil, objects = nil, time_zone = nil) ⇒ FreeBusyGenerator
constructor
Creates the generator.
-
#objects=(objects) ⇒ void
Sets the input objects.
-
#result ⇒ Component
Parses the input data and returns a correct VFREEBUSY object, wrapped in a VCALENDAR.
-
#time_range=(range) ⇒ void
Sets the time range.
-
#v_availability=(vcalendar) ⇒ void
Sets a VAVAILABILITY document.
Constructor Details
#initialize(start = nil, ending = nil, objects = nil, time_zone = nil) ⇒ FreeBusyGenerator
Creates the generator.
Check the setTimeRange and setObjects methods for details about the arguments.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/tilia/v_object/free_busy_generator.rb', line 62 def initialize(start = nil, ending = nil, objects = nil, time_zone = nil) start = Time.zone.parse(Settings.min_date) unless start ending = Time.zone.parse(Settings.max_date) unless ending self.time_range = start..ending @objects = [] self.objects = objects if objects time_zone = ActiveSupport::TimeZone.new('UTC') unless time_zone self.time_zone = time_zone end |
Instance Attribute Details
#base_object=(value) ⇒ void (writeonly)
This method returns an undefined value.
Sets the VCALENDAR object.
If this is set, it will not be generated for you. You are responsible for setting things like the METHOD, CALSCALE, VERSION, etc..
The VFREEBUSY object will be automatically added though.
83 84 85 |
# File 'lib/tilia/v_object/free_busy_generator.rb', line 83 def base_object=(value) @base_object = value end |
#time_zone=(value) ⇒ void (writeonly)
This method returns an undefined value.
Sets the reference timezone for floating times.
135 136 137 |
# File 'lib/tilia/v_object/free_busy_generator.rb', line 135 def time_zone=(value) @time_zone = value end |
Instance Method Details
#objects=(objects) ⇒ void
This method returns an undefined value.
Sets the input objects.
You must either specify a valendar object as a string, or as the parse Component. It’s also possible to specify multiple objects as an array.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/tilia/v_object/free_busy_generator.rb', line 102 def objects=(objects) objects = [objects] unless objects.is_a?(Array) @objects = [] objects.each do |object| if object.is_a?(String) @objects << Reader.read(object) elsif object.is_a?(Component) @objects << object else fail ArgumentError, 'You can only pass strings or Component arguments to setObjects' end end end |
#result ⇒ Component
Parses the input data and returns a correct VFREEBUSY object, wrapped in a VCALENDAR.
141 142 143 144 145 146 147 148 |
# File 'lib/tilia/v_object/free_busy_generator.rb', line 141 def result fb_data = FreeBusyData.new(@start.to_i, @end.to_i) calculate_availability(fb_data, @vavailability) if @vavailability calculate_busy(fb_data, @objects) generate_free_busy_calendar(fb_data) end |
#time_range=(range) ⇒ void
This method returns an undefined value.
Sets the time range.
Any freebusy object falling outside of this time range will be ignored.
125 126 127 128 |
# File 'lib/tilia/v_object/free_busy_generator.rb', line 125 def time_range=(range) @start = range.begin @end = range.end end |
#v_availability=(vcalendar) ⇒ void
This method returns an undefined value.
Sets a VAVAILABILITY document.
89 90 91 |
# File 'lib/tilia/v_object/free_busy_generator.rb', line 89 def v_availability=(vcalendar) @vavailability = vcalendar end |