Class: RiCal::Component::TZInfoTimezone::Periods

Inherits:
Object
  • Object
show all
Defined in:
lib/ri_cal/component/t_z_info_timezone.rb

Overview

:nodoc: all

Instance Method Summary collapse

Constructor Details

#initializePeriods

Returns a new instance of Periods.



68
69
70
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 68

def initialize
  @dst_period = @std_period = @previous_period = nil
end

Instance Method Details

#add_period(this_period, force = false) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 89

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



76
77
78
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 76

def daylight_period(this_period, previous_period)
  @daylight_period ||= Period.new("DAYLIGHT", this_period, previous_period)
end

#empty?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 72

def empty?
  @periods.nil? || @periods.empty?
end

#export_to(export_stream) ⇒ Object



102
103
104
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 102

def export_to(export_stream)
  @periods.each {|period| period.export_to(export_stream)}
end

#log_period(period) ⇒ Object



84
85
86
87
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 84

def log_period(period)
  @periods ||= []
  @periods << period unless @periods.include?(period)
end

#standard_period(this_period, previous_period) ⇒ Object



80
81
82
# File 'lib/ri_cal/component/t_z_info_timezone.rb', line 80

def standard_period(this_period, previous_period)
  @standard_period ||= Period.new("STANDARD", this_period, previous_period)
end