Class: CalFilter::CalendarWrapper

Inherits:
ResourceWrapper show all
Defined in:
lib/calfilter.rb

Constant Summary collapse

RESOURCE_TYPES =
%w{events freebusys journals todos}

Constants included from TripIt

TripIt::EVENT_TYPES

Instance Method Summary collapse

Methods inherited from ResourceWrapper

#__action__, #__delegate__, #__kind__

Methods included from TripIt

#tripit_type

Constructor Details

#initialize(calendar) ⇒ CalendarWrapper

Returns a new instance of CalendarWrapper.



72
73
74
# File 'lib/calfilter.rb', line 72

def initialize(calendar)
  super(calendar, 'calendar')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



92
93
94
95
96
97
98
# File 'lib/calfilter.rb', line 92

def method_missing(symbol, *args, &block)
  if symbol.to_s =~ /^filter_(.*)$/ && RESOURCE_TYPES.include?($1)
    __filter_resource__($1, *args, &block)
  else
    super(symbol, *args, &block)
  end
end

Instance Method Details

#keep(*args) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/calfilter.rb', line 84

def keep(*args)
  if args.empty?
    super
  else
    __remove_elements__ :keep, RESOURCE_TYPES.map{|t|t.to_sym} - args
  end
end

#remove(*args) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/calfilter.rb', line 76

def remove(*args)
  if args.empty?
    super
  else
    __remove_elements__ :remove, args
  end
end