Class: When::V::Calendar

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

Overview

ひとつの ics 形式ファイルをまとめて保持する

BEGIN:VCALENADR...END:VCALENDAR のブロックに対応

Constant Summary collapse

Properties =
[['prodid', 'version'], [],
['method'], [], []]
Classes =
nil

Constants inherited from Root

Root::AwareProperties, Root::DefaultOptional, Root::DefaultUnique

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Instance Attribute Summary collapse

Attributes inherited from Root

#calscale, #property

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#_pool, #keys, #locale, #namespace

Instance Method Summary collapse

Methods inherited from Root

#_enumerator, #include?

Methods included from Parts::Resource

#[], #^, _decode, _encode, _extract_prefix, _instance, _parse, _path_with_prefix, _replace_tags, _setup_, #each, #enum_for, #hierarchy, #include?, #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

#childObject

Returns the value of attribute child.



482
483
484
# File 'lib/when_exe/icalendar.rb', line 482

def child
  @child
end

Instance Method Details

#_enumerator_list(args) ⇒ Object



510
511
512
513
514
# File 'lib/when_exe/icalendar.rb', line 510

def _enumerator_list(args)
  (@child.reject {|el| !el.kind_of?(Event)}).inject([]) { |sum, ev|
    sum += ev._enumerator_list(args)
  }
end

#intersection(keys = {}) ⇒ When::V::Calendar

When::V::Event の検索

Parameters:

  • keys (Hash) (defaults to: {})

    { key => value }

Returns:

  • (When::V::Calendar)

    key で指定する Property の値が value に一致する When::V::Event のみを持つ self の複製を作る (一致の判断は演算子 === による)



492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/when_exe/icalendar.rb', line 492

def intersection(keys={})
  copy = self.dup
  copy.child = @child.select {|ev|
    if ev.kind_of?(Event)
      keys.each_pair do |key, value|
        case value
        when String ; break unless ev.property[key].object.index(value)
        when Regexp ; break unless (ev.property[key].object =~ value)
        end
      end
    else
      true
    end
  }
  return copy
end