Class: MList::Thread
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MList::Thread
- Defined in:
- lib/mlist/thread.rb
Defined Under Namespace
Classes: Node
Instance Method Summary collapse
- #first?(message) ⇒ Boolean
- #last?(message) ⇒ Boolean
- #next(message) ⇒ Object
- #previous(message) ⇒ Object
- #subject ⇒ Object
-
#tree ⇒ Object
Answers a tree of messages.
- #tree_order ⇒ Object
Instance Method Details
#first?(message) ⇒ Boolean
8 9 10 |
# File 'lib/mlist/thread.rb', line 8 def first?() tree_order.first == end |
#last?(message) ⇒ Boolean
12 13 14 |
# File 'lib/mlist/thread.rb', line 12 def last?() tree_order.last == end |
#next(message) ⇒ Object
16 17 18 19 |
# File 'lib/mlist/thread.rb', line 16 def next() i = tree_order.index() tree_order[i + 1] unless .size < i end |
#previous(message) ⇒ Object
21 22 23 24 |
# File 'lib/mlist/thread.rb', line 21 def previous() i = tree_order.index() tree_order[i - 1] if i > 0 end |
#subject ⇒ Object
26 27 28 |
# File 'lib/mlist/thread.rb', line 26 def subject .first.subject end |
#tree ⇒ Object
Answers a tree of messages.
The nodes of the tree are decorated to act like a linked list, providing pointers to next and previous in the tree.
35 36 37 38 39 |
# File 'lib/mlist/thread.rb', line 35 def tree return nil if .size == 0 build_tree unless @tree @tree end |
#tree_order ⇒ Object
41 42 43 44 |
# File 'lib/mlist/thread.rb', line 41 def tree_order build_tree unless @tree @tree_order end |