Class: RRule
- Inherits:
-
Object
- Object
- RRule
- Defined in:
- lib/rrule.rb
Constant Summary collapse
- RRULE =
'RRULE'- EXRULE =
'EXRULE'- VEVENT =
'VEVENT'
Instance Method Summary collapse
- #count ⇒ Object
-
#count=(new_count) ⇒ Object
Options
new_count:: number of count. -
#days ⇒ Object
Gets the WeekdayNums for the recurrence rule WeekdayNum is an object which specifies the week of year and the day of week.
-
#days=(new_days) ⇒ Object
Sets the WeekdayNums for the recurrence rule WeekdayNum is an object which specifies the week of year and the day of week.
-
#ext_params ⇒ Object
Returns a hash map of any extension parameters such as the X-FOO=BAR in RRULE;X-FOO=BAR.
-
#frequency ⇒ Object
Gets the recurrence frequency, return type is defined in “com.google.ical.values.Frequency”, such as Frequency::MONTHLY.
-
#frequency=(freq) ⇒ Object
Sets the recurrence frequency.
- #hours ⇒ Object
-
#hours=(new_hours = []) ⇒ Object
Options
new_hours:: array of numbers (0..23). -
#initialize(ical_string = nil) ⇒ RRule
constructor
Initializes a Recurrence Rule with optionally an iCal string.
- #interval ⇒ Object
- #interval=(new_interval) ⇒ Object
-
#mdays ⇒ Object
Gets the days of month.
-
#mdays=(new_mdays = []) ⇒ Object
Sets the days of month.
-
#method_missing(key, *params) ⇒ Object
We should consider getting rid of this or implement this using meta-programming.
- #minutes ⇒ Object
-
#minutes=(new_minutes = []) ⇒ Object
Options
new_minutes:: array of numbers (0..59). - #months ⇒ Object
-
#months=(new_months = []) ⇒ Object
Options
new_months:: array of numbers (1..12). -
#name ⇒ Object
Returns the type of the recurrence rule such as RRULE, EXRULE, or VEVENT.
-
#name=(new_name) ⇒ Object
Sets the type of the recurrence rule such as RRULE, EXRULE, or VEVENT.
- #seconds ⇒ Object
-
#seconds=(new_seconds = []) ⇒ Object
Options
new_seconds:: array of days of month (0..59). - #setpos ⇒ Object
- #setpos=(new_setpos = []) ⇒ Object
-
#to_ical ⇒ Object
Returns the unfolded RFC 2445 content line.
-
#to_java ⇒ Object
Returns the underlying Java object.
-
#until ⇒ Object
Gets the end date.
-
#until=(new_date) ⇒ Object
Sets the end date.
-
#wdaystart ⇒ Object
Gets the starting day of the week (0-6).
-
#wdaystart=(wday) ⇒ Object
Sets the starting day of the week (0-6, Mon-Sun, Mo-Su).
- #weeknums ⇒ Object
-
#weeknums=(new_weeknums = []) ⇒ Object
Sets the numbers of week.
-
#ydays ⇒ Object
Gets the day of year.
-
#ydays=(new_ydays = []) ⇒ Object
Sets the day of year.
Constructor Details
#initialize(ical_string = nil) ⇒ RRule
Initializes a Recurrence Rule with optionally an iCal string
Options
ical_string-
Optional. The iCal string for the recurrent rule. The string must specify the rule type (RRULE, EXRULE or VEVENT)
17 18 19 20 |
# File 'lib/rrule.rb', line 17 def initialize(ical_string=nil) @rrule = ical_string ? JRRule.new(ical_string) : JRRule.new self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *params) ⇒ Object
We should consider getting rid of this or implement this using meta-programming
241 242 243 |
# File 'lib/rrule.rb', line 241 def method_missing(key, *params) @rrule.send(key, *params) end |
Instance Method Details
#count ⇒ Object
42 43 44 |
# File 'lib/rrule.rb', line 42 def count @rrule.getCount end |
#count=(new_count) ⇒ Object
Options
new_count-
number of count
48 49 50 51 |
# File 'lib/rrule.rb', line 48 def count=(new_count) @rrule.setCount(new_count) self end |
#days ⇒ Object
Gets the WeekdayNums for the recurrence rule WeekdayNum is an object which specifies the week of year and the day of week
191 192 193 194 195 |
# File 'lib/rrule.rb', line 191 def days @rrule.getByDay.to_a.map do |d| WeekdayNum.new(d) end end |
#days=(new_days) ⇒ Object
Sets the WeekdayNums for the recurrence rule WeekdayNum is an object which specifies the week of year and the day of week
Options
new_days-
Array of WeekdayNums
203 204 205 206 |
# File 'lib/rrule.rb', line 203 def days=(new_days) @rrule.setByDay(new_days.map {|d| d.to_java}) self end |
#ext_params ⇒ Object
Returns a hash map of any extension parameters such as the X-FOO=BAR in RRULE;X-FOO=BAR
34 35 36 37 38 39 40 |
# File 'lib/rrule.rb', line 34 def ext_params h = {} @rrule.getExtParams.to_a.each do |p| h[p[0]] = p[1] end h end |
#frequency ⇒ Object
Gets the recurrence frequency, return type is defined in “com.google.ical.values.Frequency”, such as Frequency::MONTHLY
149 150 151 |
# File 'lib/rrule.rb', line 149 def frequency @rrule.getFreq end |
#frequency=(freq) ⇒ Object
Sets the recurrence frequency
Options
freq-
defined in com.google.ical.values.Frequency, such as Frequency::MONTHLY or Frequency::DAILY
158 159 160 161 |
# File 'lib/rrule.rb', line 158 def frequency=(freq) @rrule.setFreq(freq) self end |
#hours ⇒ Object
53 54 55 |
# File 'lib/rrule.rb', line 53 def hours @rrule.getByHour.to_a end |
#hours=(new_hours = []) ⇒ Object
Options
new_hours-
array of numbers (0..23)
59 60 61 62 |
# File 'lib/rrule.rb', line 59 def hours=(new_hours=[]) @rrule.setByHour(new_hours.to_java(:int)) self end |
#interval ⇒ Object
163 164 165 |
# File 'lib/rrule.rb', line 163 def interval @rrule.getInterval end |
#interval=(new_interval) ⇒ Object
167 168 169 170 |
# File 'lib/rrule.rb', line 167 def interval=(new_interval) @rrule.setInterval(new_interval) self end |
#mdays ⇒ Object
Gets the days of month
87 88 89 |
# File 'lib/rrule.rb', line 87 def mdays @rrule.getByMonthDay.to_a end |
#mdays=(new_mdays = []) ⇒ Object
Sets the days of month
Options
new_mdays-
array of days of month (1..31)
95 96 97 98 |
# File 'lib/rrule.rb', line 95 def mdays=(new_mdays=[]) @rrule.setByMonthDay(new_mdays.to_java(:int)) self end |
#minutes ⇒ Object
64 65 66 |
# File 'lib/rrule.rb', line 64 def minutes @rrule.getByMinute.to_a end |
#minutes=(new_minutes = []) ⇒ Object
Options
new_minutes-
array of numbers (0..59)
70 71 72 73 |
# File 'lib/rrule.rb', line 70 def minutes=(new_minutes=[]) @rrule.setByMinute(new_minutes.to_java(:int)) self end |
#months ⇒ Object
75 76 77 |
# File 'lib/rrule.rb', line 75 def months @rrule.getByMonth.to_a end |
#months=(new_months = []) ⇒ Object
Options
new_months-
array of numbers (1..12)
81 82 83 84 |
# File 'lib/rrule.rb', line 81 def months=(new_months=[]) @rrule.setByMonth(new_months.to_java(:int)) self end |
#name ⇒ Object
Returns the type of the recurrence rule such as RRULE, EXRULE, or VEVENT
174 175 176 |
# File 'lib/rrule.rb', line 174 def name @rrule.getName end |
#name=(new_name) ⇒ Object
Sets the type of the recurrence rule such as RRULE, EXRULE, or VEVENT
Options
new_name-
‘RRULE’, ‘EXRULE’, or ‘VEVENT’
183 184 185 186 |
# File 'lib/rrule.rb', line 183 def name=(new_name) @rrule.setName(new_name) self end |
#seconds ⇒ Object
100 101 102 |
# File 'lib/rrule.rb', line 100 def seconds @rrule.getBySecond.to_a end |
#seconds=(new_seconds = []) ⇒ Object
Options
new_seconds-
array of days of month (0..59)
106 107 108 109 |
# File 'lib/rrule.rb', line 106 def seconds=(new_seconds=[]) @rrule.setBySecond(new_seconds.to_java(:int)) self end |
#setpos ⇒ Object
111 112 113 |
# File 'lib/rrule.rb', line 111 def setpos @rrule.getBySetPos.to_a end |
#setpos=(new_setpos = []) ⇒ Object
115 116 117 118 |
# File 'lib/rrule.rb', line 115 def setpos=(new_setpos=[]) @rrule.setByPos(new_setpos.to_java(:int)) self end |
#to_ical ⇒ Object
Returns the unfolded RFC 2445 content line.
28 29 30 |
# File 'lib/rrule.rb', line 28 def to_ical @rrule.toIcal end |
#to_java ⇒ Object
Returns the underlying Java object
23 24 25 |
# File 'lib/rrule.rb', line 23 def to_java @rrule end |
#until ⇒ Object
Gets the end date
225 226 227 228 |
# File 'lib/rrule.rb', line 225 def until d = @rrule.getUntil d ? JTime.local(d.year, d.month, d.day, d.hour, d.minute, d.second) : nil end |
#until=(new_date) ⇒ Object
Sets the end date
Options
new_date-
JTime object
234 235 236 237 238 |
# File 'lib/rrule.rb', line 234 def until=(new_date) d = com.google.ical.values.DateTimeValueImpl.new(new_date.year, new_date.month, new_date.day, new_date.hour, new_date.min, new_date.sec) @rrule.setUntil(d) self end |
#wdaystart ⇒ Object
Gets the starting day of the week (0-6)
209 210 211 212 |
# File 'lib/rrule.rb', line 209 def wdaystart weekday = @rrule.getWkSt Weekday::MAP[weekday] end |
#wdaystart=(wday) ⇒ Object
Sets the starting day of the week (0-6, Mon-Sun, Mo-Su)
Options
wday-
0-6, ‘Mon’ - ‘Sun’, or ‘Mo’ - ‘Su’
218 219 220 221 222 |
# File 'lib/rrule.rb', line 218 def wdaystart=(wday) wday = Weekday::MAP[wday.to_s.downcase] @rrule.setWkSt(wday) self end |
#weeknums ⇒ Object
120 121 122 |
# File 'lib/rrule.rb', line 120 def weeknums @rrule.getByWeekNo.to_a end |
#weeknums=(new_weeknums = []) ⇒ Object
Sets the numbers of week
Options
new_weeknums-
array of weeks (1..52)
128 129 130 131 |
# File 'lib/rrule.rb', line 128 def weeknums=(new_weeknums=[]) @rrule.setByWeekNo(new_weeknums.to_java(:int)) self end |
#ydays ⇒ Object
Gets the day of year
134 135 136 |
# File 'lib/rrule.rb', line 134 def ydays @rrule.getByYearDay.to_a end |
#ydays=(new_ydays = []) ⇒ Object
Sets the day of year
Options
new_ydays-
array of day of year (1..365)
142 143 144 145 |
# File 'lib/rrule.rb', line 142 def ydays=(new_ydays=[]) @rrule.setByYearDay(new_ydays.to_java(:int)) self end |