PageSet (Class)

In: app/models/page_set.rb
Parent: Array

Container for a set of pages with methods for manipulation.

Attributes

web  [R] 

Public Class methods

[Source]

    # 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

Public Instance methods

[Source]

    # File app/models/page_set.rb, line 61
61:   def authors
62:     self.inject([]) { |authors, page| authors << page.authors }.flatten.uniq.sort
63:   end

[Source]

    # File app/models/page_set.rb, line 18
18:   def by_name
19:     self.sort_by { |page| [page.name] } 
20:   end

[Source]

    # File app/models/page_set.rb, line 22
22:   def by_revision
23:     self.sort_by { |page| [page.created_at] }.reverse 
24:   end

[Source]

    # File app/models/page_set.rb, line 34
34:   def characters
35:     self.inject(0) { |chars,page| chars += page.content.size }
36:   end

[Source]

    # 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

[Source]

    # File app/models/page_set.rb, line 53
53:   def names
54:     self.map { |page| page.name }
55:   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

[Source]

    # 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

[Source]

    # File app/models/page_set.rb, line 30
30:   def pages_authored_by(author)
31:     self.select { |page| page.authors.include?(author) }
32:   end

[Source]

    # 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

[Source]

    # File app/models/page_set.rb, line 49
49:   def wanted_pages
50:     wiki_words - web.select.names
51:   end

[Source]

    # File app/models/page_set.rb, line 57
57:   def wiki_words
58:     self.inject([]) { |wiki_words, page| wiki_words << page.wiki_words }.flatten.uniq
59:   end

[Validate]