class Gumdrop::ContentList
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/gumdrop/content.rb, line 196 def initialize @cache = {} super end
Public Instance Methods
add(content, uri=nil)
click to toggle source
# File lib/gumdrop/content.rb, line 206 def add(content, uri=nil) uri= content.uri if uri.nil? self[uri]= content content end
all(pattern=nil)
click to toggle source
Returns Array of content objects
# File lib/gumdrop/content.rb, line 218 def all(pattern=nil) pattern.nil? ? values : find(pattern) end
clear()
click to toggle source
Calls superclass method
# File lib/gumdrop/content.rb, line 234 def clear @cache.clear() super end
create(path, generator=nil, &block)
click to toggle source
# File lib/gumdrop/content.rb, line 201 def create(path, generator=nil, &block) content= Content.new path, generator, &block add content #, path end
find(pattern)
click to toggle source
Scans the filenames (keys) and uses fnmatch to find maches
# File lib/gumdrop/content.rb, line 223 def find(pattern) patterns= [pattern].flatten contents=[] self.each_pair do |path, content| patterns.each do |pattern| contents << content if Content.path_match? path, pattern end end contents end
first(pattern)
click to toggle source
# File lib/gumdrop/content.rb, line 243 def first(pattern) if @cache.has_key? pattern @cache[pattern] else @cache[pattern]= find(pattern).first end end
get(key)
click to toggle source
# File lib/gumdrop/content.rb, line 239 def get(key) self[key] end
remove(content)
click to toggle source
# File lib/gumdrop/content.rb, line 212 def remove(content) uri = content.is_a? String ? content : content.uri self.delete uri end