Module: CalFilter
- Defined in:
- lib/calfilter.rb,
lib/calfilter/cgi.rb,
lib/calfilter/tripit.rb
Defined Under Namespace
Modules: TripIt
Classes: CGIWrapper, CalendarWrapper, FilterError, ResourceWrapper
Constant Summary
collapse
- VERSION =
'1.1.3'
- CGIWRAPPER =
make_cgi_wrapper
Class Method Summary
collapse
Class Method Details
.keep_or_delete_items(items, type, actions) ⇒ Object
134
135
136
137
138
139
140
141
142
|
# File 'lib/calfilter.rb', line 134
def self.keep_or_delete_items(items, type, actions)
if actions.include?(:keep) && actions.include?(:remove)
raise CalFilter::FilterError, "Cannot both keep and remove #{type} in the same group.", caller(2)
end
keep_action = (actions.include?(:keep) ? :keep : :default)
kept_items = []
items.each_with_index{|item, i| kept_items << item if actions[i] == keep_action}
kept_items
end
|
.make_cgi_wrapper ⇒ Object
28
29
30
|
# File 'lib/calfilter/cgi.rb', line 28
def self.make_cgi_wrapper
CGIWrapper.new(StringIO.new)
end
|
.output_stream ⇒ Object
9
10
11
|
# File 'lib/calfilter.rb', line 9
def self.output_stream
@output_stream
end
|
.output_stream=(stream) ⇒ Object
13
14
15
|
# File 'lib/calfilter.rb', line 13
def self.output_stream=(stream)
@output_stream = stream
end
|
.wrap_calendar(cal) ⇒ Object
124
125
126
|
# File 'lib/calfilter.rb', line 124
def self.wrap_calendar(cal)
CalendarWrapper.new(cal)
end
|
.wrap_resource(res, plural_resource_type) ⇒ Object
128
129
130
131
132
|
# File 'lib/calfilter.rb', line 128
def self.wrap_resource(res, plural_resource_type)
singular_resource_type = plural_resource_type.sub(/s$/, '')
ResourceWrapper.new(res, singular_resource_type)
end
|