Class: CalFilter::ResourceWrapper

Inherits:
Object
  • Object
show all
Includes:
TripIt
Defined in:
lib/calfilter.rb,
lib/calfilter/tripit.rb

Overview

A filtering wrapper for an Icalendar resource object. The wrapped object will be one of:

All unrecognized methods are delegated to the underlying resource object, so methods such as #description and #summary work as expected. (The resource object can be accessed directly using the #__delegate__ method.)

In addition to delegating to the resource, ResourceWrapper objects provide a few additional methods:

  • #_delegate_

  • #keep

  • #remove

Direct Known Subclasses

CalendarWrapper

Constant Summary

Constants included from TripIt

TripIt::EVENT_TYPES

Instance Method Summary collapse

Methods included from TripIt

#tripit_type

Constructor Details

#initialize(delegate, kind) ⇒ ResourceWrapper

:nodoc:



45
46
47
48
# File 'lib/calfilter.rb', line 45

def initialize(delegate, kind)  # :nodoc:
  @delegate = delegate
  @kind = kind
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object

:nodoc:



81
82
83
# File 'lib/calfilter.rb', line 81

def method_missing(symbol, *args, &block)     # :nodoc:
  __delegate__.send(symbol, *args, &block)
end

Instance Method Details

#__action__Object

:nodoc:



55
56
57
# File 'lib/calfilter.rb', line 55

def __action__    # :nodoc:
  @keep_or_remove || :default
end

#__delegate__Object

Provides access to the underlying resource being wrapped.



51
52
53
# File 'lib/calfilter.rb', line 51

def __delegate__
  @delegate
end

#__kind__Object

:nodoc:



59
60
61
# File 'lib/calfilter.rb', line 59

def __kind__      # :nodoc:
  @kind
end

#keepObject

Marks this resource to be kept in the calendar.

If this is called on some resources, all others in the collection will be removed. For a particular kind of resource (e.g., events, todos, journals) in a given calendar, you can call either #remove or #keep on some of the resources, but not both.



77
78
79
# File 'lib/calfilter.rb', line 77

def keep
  __flag__ :keep
end

#removeObject

Marks this resource for removal from the calendar. For a particular kind of resource (e.g., events, todos, journals) in a given calendar, you can call either #remove or #keep on some of the resources, but not both.



67
68
69
# File 'lib/calfilter.rb', line 67

def remove
  __flag__ :remove
end