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.



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

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

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



145
146
147
# File 'lib/frill/frill.rb', line 145

def label
  @label
end

#nextObject

Returns the value of attribute next.



144
145
146
# File 'lib/frill/frill.rb', line 144

def next
  @next
end

#previousObject

Returns the value of attribute previous.



144
145
146
# File 'lib/frill/frill.rb', line 144

def previous
  @previous
end

Instance Method Details

#firstObject



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

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

#lastObject



167
168
169
170
171
# File 'lib/frill/frill.rb', line 167

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

#move_before(node) ⇒ Object



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

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

  previous_node.next = next_node
  next_node.previous = previous_node
end