Class: Frill::DependencyGraph::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/frill/frill.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label) ⇒ Node

Returns a new instance of Node.



140
141
142
143
144
# File 'lib/frill/frill.rb', line 140

def initialize(label)
  @label  = label
  @next = nil
  @previous  = nil
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



138
139
140
# File 'lib/frill/frill.rb', line 138

def label
  @label
end

#nextObject

Returns the value of attribute next.



137
138
139
# File 'lib/frill/frill.rb', line 137

def next
  @next
end

#previousObject

Returns the value of attribute previous.



137
138
139
# File 'lib/frill/frill.rb', line 137

def previous
  @previous
end

Instance Method Details

#firstObject



154
155
156
157
158
# File 'lib/frill/frill.rb', line 154

def first
  first_node = self
  first_node = first_node.previous while first_node.previous
  first_node
end

#lastObject



160
161
162
163
164
# File 'lib/frill/frill.rb', line 160

def last
  last_node = self
  last_node = last_node.next while last_node.next
  last_node
end

#move_before(node) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/frill/frill.rb', line 146

def move_before node
  next_node = node.first
  previous_node = self.last

  previous_node.next = next_node
  next_node.previous = previous_node
end