Class: When::V::Root

Inherits:
BasicTypes::Object show all
Defined in:
lib/when_exe/icalendar.rb

Overview

iCalendar を構成するクラス群の共通抽象クラス

RFC 5545 のクラスは、有無のチェックを除いてProperty の扱いが共通なので、
Property の扱いを、本クラスにまとめて記述している。

Direct Known Subclasses

Calendar, Event, Timezone

Constant Summary collapse

Properties =
[[],[],[],[],[]]
Classes =
nil
DefaultUnique =
['calscale', 'namespace', 'locale']
DefaultOptional =
['x_prop', 'iana_prop']
AwareProperties =
DefaultUnique + 
                      ['tzoffsetfrom', 'tzoffsetto', 'tzname',
'dtstart', 'dtend', 'due',
'repeat', 'duration',
'rrule', 'rdate', 'exdate', 'exevent',
'summary', 'freebusy']

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary collapse

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Instance Method Summary collapse

Methods included from Parts::Resource

#[], #^, _decode, _encode, _extract_prefix, _instance, _parse, _path_with_prefix, _replace_tags, _setup_, #each, #hierarchy, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?

Methods included from Parts::Resource::Pool

#[], #[]=, #_pool, #_setup_, #pool_keys

Methods included from Parts::Resource::Synchronize

#synchronize

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::Parts::Resource

Instance Attribute Details

#calscaleWhen::TM::Calendar (readonly)

Note:

RFC 5545 では、‘GREGORIAN’ のみ指定可能としている。 CALSCALE Property 文字列を capitalize したものに、 prefix _c:(=hosi.org/When/CalendarTypes/)を補い When::TM::Calendar オブジェクトの定義を取得する。

デフォルトのWhen::TM::Calendar

Returns:



104
105
106
# File 'lib/when_exe/icalendar.rb', line 104

def calscale
  @calscale
end

#propertyHash (readonly)

iCalendar クラス群の属性

Returns:

  • (Hash)

    { String => When::Parts::Resource::ContentLine }



92
93
94
# File 'lib/when_exe/icalendar.rb', line 92

def property
  @property
end

Instance Method Details

#_enumerator(*args) ⇒ Object Also known as: to_enum, enum_for

イテレータの生成

Raises:

  • (ArgumentError)


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/when_exe/icalendar.rb', line 123

def _enumerator(*args)
  options = When::Parts::Enumerator._options(args)
  args << options
  exdate  = options[:exdate]

  enumerators = _enumerator_list(args)
  raise ArgumentError, "No enumerator exists" if (enumerators.length==0)

  # Enumerator の生成
  enumerator =
    if (enumerators.length==1 && exdate.node.size==0)
      enumerators[0]
    else
      options[:exdate] = exdate
      When::Parts::Enumerator::Integrated.new(self, enumerators, *args)
    end
  if ::Object.const_defined?(:Date) && (args[0].kind_of?(Range) ? args[0].first : args[0]).kind_of?(::Date)
    enumerator.instance_eval %Q{
      alias :_succ_of_super :succ
      def succ
        result = _succ_of_super
        case result
        when When::TM::DateAndTime ; result.to_date_time
        when When::TM::CalDate     ; result.to_date
        else                       ; result
        end
      end
    }
  end
  enumerator
end

#include?(date) ⇒ Boolean

指定の日時を含むか?

Parameters:

Returns:

  • (Boolean)
    true - 含む
    false - 含まない


114
115
116
117
118
119
# File 'lib/when_exe/icalendar.rb', line 114

def include?(date)
  first = enum_for(date).next
  return first.include?(date) if first.kind_of?(When::Parts::GeometricComplex)
  return first == date if first.precision <= date.precision
  return false
end