Class: Gumdrop::SpecialContentList

Inherits:
ContentList show all
Defined in:
lib/gumdrop/content.rb

Overview

Keeps a ref to content at full path and just the basename

Instance Method Summary collapse

Methods inherited from ContentList

#all, #clear, #create, #first, #get

Methods inherited from Hash

#ends_with?, #starts_with?, #to_hash_object, #to_symbolized_hash

Constructor Details

#initialize(default_ext = false) ⇒ SpecialContentList

, *args)



256
257
258
259
# File 'lib/gumdrop/content.rb', line 256

def initialize(default_ext=false)#, *args)
  @ext= default_ext || ".html"  # ???
  super()
end

Instance Method Details

#add(content, uri = nil) ⇒ Object



261
262
263
264
265
266
267
# 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) ⇒ Object

Find isn’t fuzzy for Special Content. It looks for full uri or the uri’s basename, optionally tacking on @ext



277
278
279
280
281
282
283
# 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) ⇒ Object



269
270
271
272
273
# 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