Class: Gumdrop::ContentList
- Inherits:
-
Hash
- Object
- Hash
- Gumdrop::ContentList
show all
- Defined in:
- lib/gumdrop/content.rb
Instance Method Summary
collapse
Methods inherited from Hash
#ends_with?, #starts_with?, #to_hash_object, #to_symbolized_hash
Instance Method Details
#add(content, uri = nil) ⇒ Object
181
182
183
184
185
|
# File 'lib/gumdrop/content.rb', line 181
def add(content, uri=nil)
uri= content.uri if uri.nil?
self[uri]= content
content
end
|
#all(pattern = nil) ⇒ Object
Returns Array of content objects
193
194
195
|
# File 'lib/gumdrop/content.rb', line 193
def all(pattern=nil)
pattern.nil? ? values : find(pattern)
end
|
#create(path, generator = nil, &block) ⇒ Object
176
177
178
179
|
# File 'lib/gumdrop/content.rb', line 176
def create(path, generator=nil, &block)
content= Content.new path, generator, &block
add content end
|
#find(pattern) ⇒ Object
Scans the filenames (keys) and uses fnmatch to find maches
198
199
200
201
202
203
204
205
206
207
|
# File 'lib/gumdrop/content.rb', line 198
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) ⇒ Object
213
214
215
|
# File 'lib/gumdrop/content.rb', line 213
def first(pattern)
find(pattern).first
end
|
#get(key) ⇒ Object
209
210
211
|
# File 'lib/gumdrop/content.rb', line 209
def get(key)
self[key]
end
|
#remove(content) ⇒ Object
187
188
189
190
|
# File 'lib/gumdrop/content.rb', line 187
def remove(content)
uri = content.is_a? String ? content : content.uri
self.delete uri
end
|