Class: RiCal::Component::Timezone::TimezonePeriod

Inherits:
RiCal::Component show all
Includes:
OccurrenceEnumerator, Properties::TimezonePeriod
Defined in:
lib/ri_cal/component/timezone/timezone_period.rb

Overview

  • ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license

A TimezonePeriod is a component of a timezone representing a period during which a particular offset from UTC is in effect.

to see the property accessing methods for this class see the RiCal::Properties::TimezonePeriod module

Direct Known Subclasses

DaylightPeriod, StandardPeriod

Instance Attribute Summary

Attributes inherited from RiCal::Component

#imported

Instance Method Summary collapse

Methods included from OccurrenceEnumerator

#after_range?, #before_range?, #bounded?, #default_duration, #default_start_time, #each, #occurrences, #recurrence, #recurs?, #set_occurrence_properties!, #zulu_occurrence_range

Methods included from Properties::TimezonePeriod

#==, #add_comment, #add_comments, #add_date_times_to, #add_rdate, #add_rdates, #add_rrule, #add_rrules, #add_tzname, #add_tznames, #comment, #comment=, #comment_property, #comment_property=, #comment_property_from_string, #comments=, #dtstart, #dtstart=, #dtstart_property, #dtstart_property=, #dtstart_property_from_string, #export_properties_to, included, #initialize_copy, #mutual_exclusion_violation, #rdate, #rdate=, #rdate_property, #rdate_property=, #rdate_property_from_string, #rdates=, #remove_comment, #remove_comments, #remove_rdate, #remove_rdates, #remove_rrule, #remove_rrules, #remove_tzname, #remove_tznames, #rrule, #rrule=, #rrule_property, #rrule_property=, #rrule_property_from_string, #rrules=, #tzname, #tzname=, #tzname_property, #tzname_property=, #tzname_property_from_string, #tznames=, #tzoffsetfrom, #tzoffsetfrom=, #tzoffsetfrom_property, #tzoffsetfrom_property=, #tzoffsetfrom_property_from_string, #tzoffsetto, #tzoffsetto=, #tzoffsetto_property, #tzoffsetto_property=, #tzoffsetto_property_from_string

Methods inherited from RiCal::Component

#add_property_date_times_to, #add_subcomponent, #add_x_property, #alarms, #daylight, #default_tzid, entity_name, #entity_name, #export, #export_prop_to, #export_subcomponent_to, #export_to, #export_x_properties_to, #find_timezone, from_parser, #imported?, #initialize, #initialize_copy, #last_period, #method_missing, parse, parse_string, #parse_subcomponent, #process_line, #prop_string, #standard, #subcomponent_class, #subcomponents, #time_zone_for, #to_s, #tz_info_source?, #valid?, #x_properties

Constructor Details

This class inherits a constructor from RiCal::Component

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RiCal::Component

Instance Method Details

#dtendObject

:nodoc:



23
24
25
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 23

def dtend #:nodoc:
  nil
end

#enumeration_instanceObject



69
70
71
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 69

def enumeration_instance
  @enumeration_instance ||= super
end

#exdate_propertyObject

:nodoc:



27
28
29
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 27

def exdate_property #:nodoc:
  nil
end

#exrule_propertyObject

:nodoc:



35
36
37
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 35

def exrule_property #:nodoc:
  nil
end

#fill_cache(local_time) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 43

def fill_cache(local_time)
  if occurrence_cache.empty? || occurrence_cache.last.dtstart_property <= local_time
    while true
      occurrence = enumeration_instance.next_occurrence
      break unless occurrence
      occurrence = recurrence(occurrence)
      occurrence_cache << occurrence
      break if occurrence.dtstart_property > local_time
    end
  end
end

#last_before_local(local_time) ⇒ Object

:nodoc:



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 55

def last_before_local(local_time) #:nodoc:
  if recurs?
    fill_cache(local_time)
    cand_occurrence = nil
    occurrence_cache.each do |occurrence|
      return cand_occurrence if occurrence.dtstart_property > local_time
      cand_occurrence = occurrence
    end
    return cand_occurrence
  else
    return self
  end
end

#last_before_utc(utc_time) ⇒ Object

:nodoc:



39
40
41
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 39

def last_before_utc(utc_time) #:nodoc:
  last_before_local(utc_time + tzoffsetfrom_property)
end

#occurrence_cacheObject

:nodoc:



15
16
17
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 15

def occurrence_cache #:nodoc:
  @occurrence_cache ||= []
end

#utc_total_offsetObject

:nodoc:



31
32
33
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 31

def utc_total_offset #:nodoc:
  tzoffsetto_property.to_seconds
end

#zone_identifierObject

:nodoc:



19
20
21
# File 'lib/ri_cal/component/timezone/timezone_period.rb', line 19

def zone_identifier #:nodoc:
  tzname.first
end