Class: Frill::List::Node
- Inherits:
-
Object
- Object
- Frill::List::Node
- Defined in:
- lib/frill/frill.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#next ⇒ Object
Returns the value of attribute next.
-
#previous ⇒ Object
Returns the value of attribute previous.
Instance Method Summary collapse
- #first ⇒ Object
-
#initialize(label) ⇒ Node
constructor
A new instance of Node.
- #last ⇒ Object
- #move_before(node) ⇒ Object
Constructor Details
#initialize(label) ⇒ Node
Returns a new instance of Node.
142 143 144 145 146 |
# File 'lib/frill/frill.rb', line 142 def initialize(label) @label = label @next = nil @previous = nil end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
140 141 142 |
# File 'lib/frill/frill.rb', line 140 def label @label end |
#next ⇒ Object
Returns the value of attribute next.
139 140 141 |
# File 'lib/frill/frill.rb', line 139 def next @next end |
#previous ⇒ Object
Returns the value of attribute previous.
139 140 141 |
# File 'lib/frill/frill.rb', line 139 def previous @previous end |
Instance Method Details
#first ⇒ Object
156 157 158 159 160 |
# File 'lib/frill/frill.rb', line 156 def first first_node = self first_node = first_node.previous while first_node.previous first_node end |
#last ⇒ Object
162 163 164 165 166 |
# File 'lib/frill/frill.rb', line 162 def last last_node = self last_node = last_node.next while last_node.next last_node end |
#move_before(node) ⇒ Object
148 149 150 151 152 153 154 |
# File 'lib/frill/frill.rb', line 148 def move_before node next_node = node.first previous_node = self.last previous_node.next = next_node next_node.previous = previous_node end |