Class: Doculab::TableOfContents::Page
- Inherits:
-
Object
- Object
- Doculab::TableOfContents::Page
- Defined in:
- app/models/doculab/table_of_contents.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#permalink ⇒ Object
readonly
Returns the value of attribute permalink.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #filename(extension = "textile") ⇒ Object
-
#initialize(title, parent = nil, options = {}) ⇒ Page
constructor
A new instance of Page.
- #next_page ⇒ Object
- #previous_page ⇒ Object
Constructor Details
#initialize(title, parent = nil, options = {}) ⇒ Page
Returns a new instance of Page.
55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/doculab/table_of_contents.rb', line 55 def initialize(title, parent = nil, = {}) @parent = parent @title = title @permalink = [:permalink] || title.parameterize @doc = begin Doc.find(permalink) rescue nil end end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
53 54 55 |
# File 'app/models/doculab/table_of_contents.rb', line 53 def doc @doc end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
53 54 55 |
# File 'app/models/doculab/table_of_contents.rb', line 53 def parent @parent end |
#permalink ⇒ Object (readonly)
Returns the value of attribute permalink.
53 54 55 |
# File 'app/models/doculab/table_of_contents.rb', line 53 def permalink @permalink end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
53 54 55 |
# File 'app/models/doculab/table_of_contents.rb', line 53 def title @title end |
Instance Method Details
#filename(extension = "textile") ⇒ Object
66 67 68 |
# File 'app/models/doculab/table_of_contents.rb', line 66 def filename(extension = "textile") Doc.directory.join("#{permalink}.#{extension}") end |
#next_page ⇒ Object
70 71 72 73 |
# File 'app/models/doculab/table_of_contents.rb', line 70 def next_page return nil if index.nil? TableOfContents.pages[index+1] end |
#previous_page ⇒ Object
75 76 77 78 79 |
# File 'app/models/doculab/table_of_contents.rb', line 75 def previous_page fetch_index = (index || 0)-1 return nil if fetch_index < 0 TableOfContents.pages[fetch_index] end |