| In: |
app/models/page_set.rb
|
| Parent: | Array |
Container for a set of pages with methods for manipulation.
| web | [R] |
# File app/models/page_set.rb, line 5
5: def initialize(web, pages, accept_proc)
6: @web = web
7: if accept_proc.nil? then
8: super(pages)
9: else
10: super(pages.select { |page| accept_proc[page] })
11: end
12: end
# File app/models/page_set.rb, line 61
61: def authors
62: self.inject([]) { |authors, page| authors << page.authors }.flatten.uniq.sort
63: end
# File app/models/page_set.rb, line 18
18: def by_name
19: self.sort_by { |page| [page.name] }
20: end
# File app/models/page_set.rb, line 22
22: def by_revision
23: self.sort_by { |page| [page.created_at] }.reverse
24: end
# File app/models/page_set.rb, line 34
34: def characters
35: self.inject(0) { |chars,page| chars += page.content.size }
36: end
# File app/models/page_set.rb, line 14
14: def most_recent_revision
15: self.sort_by { |page| [page.created_at] }.reverse.first.created_at
16: end
Returns all the orphaned pages in this page set. That is, pages in this set for which there is no reference in the web. The HomePage and author pages are always assumed to have references and so cannot be orphans
# File app/models/page_set.rb, line 42
42: def orphaned_pages
43: references = web.select.wiki_words + ["HomePage"] + web.select.authors
44: self.reject { |page| references.include?(page.name) }
45: end
# File app/models/page_set.rb, line 30
30: def pages_authored_by(author)
31: self.select { |page| page.authors.include?(author) }
32: end
# File app/models/page_set.rb, line 26
26: def pages_that_reference(page_name)
27: self.select { |page| page.wiki_words.include?(page_name) }
28: end
Returns all the wiki words in this page set for which there are no pages in this page set’s web
# File app/models/page_set.rb, line 49
49: def wanted_pages
50: wiki_words - web.select.names
51: end