Class: RiCal::Component::TZInfoTimezone::Periods
- Defined in:
- lib/ri_cal/component/t_z_info_timezone.rb
Overview
:nodoc: all
Instance Method Summary collapse
- #add_period(this_period, force = false) ⇒ Object
- #daylight_period(this_period, previous_period) ⇒ Object
- #empty? ⇒ Boolean
- #export_to(export_stream) ⇒ Object
-
#initialize ⇒ Periods
constructor
A new instance of Periods.
- #log_period(period) ⇒ Object
- #standard_period(this_period, previous_period) ⇒ Object
Constructor Details
#initialize ⇒ Periods
Returns a new instance of Periods.
54 55 56 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 54 def initialize @dst_period = @std_period = @previous_period = nil end |
Instance Method Details
#add_period(this_period, force = false) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 75 def add_period(this_period, force=false) if @previous_period || force if this_period.dst? period = daylight_period(this_period, @previous_period) else period = standard_period(this_period, @previous_period) end period.add_period(this_period) log_period(period) end @previous_period = this_period end |
#daylight_period(this_period, previous_period) ⇒ Object
62 63 64 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 62 def daylight_period(this_period, previous_period) @daylight_period ||= Period.new("DAYLIGHT", this_period, previous_period) end |
#empty? ⇒ Boolean
58 59 60 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 58 def empty? @periods.nil? || @periods.empty? end |
#export_to(export_stream) ⇒ Object
88 89 90 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 88 def export_to(export_stream) @periods.each {|period| period.export_to(export_stream)} end |
#log_period(period) ⇒ Object
70 71 72 73 |
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 70 def log_period(period) @periods ||= [] @periods << period unless @periods.include?(period) end |