class Gumdrop::SpecialContentList
Keeps a ref to content at full path and just the basename
Public Class Methods
new(default_ext=false)
click to toggle source
Calls superclass method
Gumdrop::ContentList::new
# File lib/gumdrop/content.rb, line 256 def initialize(default_ext=false)#, *args) @ext= default_ext || ".html" # ??? super() end
Public Instance Methods
add(content, uri=nil)
click to toggle source
# File lib/gumdrop/content.rb, line 261 def add(content, uri=nil) uri= content.uri if uri.nil? buri = File.basename uri self[uri]= content self[buri]= content content end
find(uri)
click to toggle source
Find isn’t fuzzy for Special Content
. It looks for full uri or the uri’s basename, optionally tacking on @ext
# File lib/gumdrop/content.rb, line 277 def find(uri) _try_variations_of(uri) do |path| content= get path return [content] unless content.nil? end unless uri.nil? [] end
remove(content)
click to toggle source
# File lib/gumdrop/content.rb, line 269 def remove(content) uri = content.is_a? String ? content : content.uri self.delete uri self.delete File.basename uri end
Private Instance Methods
_try_variations_of(uri) { |uri| ... }
click to toggle source
# File lib/gumdrop/content.rb, line 287 def _try_variations_of(uri) # try the uri yield uri # plus default ext yield uri + @ext urip= Pathname.new uri # just the filename yield urip.basename # filename plus default extension yield urip.basename + @ext # filename minus the ext yield urip.basename.to_s.gsub urip.extname, '' # uri minus ext yield uri.gsub urip.extname, '' end