Class: Icalendar::Timezone

Inherits:
Component show all
Defined in:
lib/icalendar/component/timezone.rb

Overview

A Timezone is unambiguously defined by the set of time measurement rules determined by the governing body for a given geographic area. These rules describe at a minimum the base offset from UTC for the time zone, often referred to as the Standard Time offset. Many locations adjust their Standard Time forward or backward by one hour, in order to accommodate seasonal changes in number of daylight hours, often referred to as Daylight Saving Time. Some locations adjust their time by a fraction of an hour. Standard Time is also known as Winter Time. Daylight Saving Time is also known as Advanced Time, Summer Time, or Legal Time in certain countries. The following table shows the changes in time zone rules in effect for New York City starting from 1967. Each line represents a description or rule for a particular observance.

Direct Known Subclasses

Daylight, Standard

Constant Summary

Constants inherited from Component

Component::CAL_EXTENSION_REGEX

Instance Attribute Summary

Attributes inherited from Component

#name, #properties

Instance Method Summary collapse

Methods inherited from Component

#chunk_lines, #custom_property, #escape_chars, #fix_conflict_with_built_in, #method_missing, #multi_property?, #multiline_property?, #new_uid, #print_component, #print_headers, #print_parameters, #print_properties, #print_subcomponents, #printer, #properties_to_print, #remove_component, #respond_to_missing?, #to_ical

Methods inherited from Base

debug, quiet

Constructor Details

#initialize(name = "VTIMEZONE") ⇒ Timezone

Returns a new instance of Timezone.



48
49
50
# File 'lib/icalendar/component/timezone.rb', line 48

def initialize(name = "VTIMEZONE")
  super(name)
end

Dynamic Method Handling

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

Instance Method Details

#add_component(component) ⇒ Object

Define a custom add component method because standard and daylight are the only components that can occur just once with their parent.



43
44
45
46
# File 'lib/icalendar/component/timezone.rb', line 43

def add_component(component)
  key = component.class.to_s.downcase.gsub('icalendar::','').to_sym
  @components[key] = component
end

#daylight(&block) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/icalendar/component/timezone.rb', line 62

def daylight(&block)
  e = Daylight.new
  self.add_component e

  e.instance_eval(&block) if block

  e
end

#standard(&block) ⇒ Object

Allow block syntax for declaration of standard and daylight components of timezone



53
54
55
56
57
58
59
60
# File 'lib/icalendar/component/timezone.rb', line 53

def standard(&block)
  e = Standard.new
  self.add_component e

  e.instance_eval(&block) if block

  e
end