Advertisement
ZaBlanc

Kata 8/25 DLL

Aug 25th, 2011
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.37 KB | None | 0 0
  1. class Color
  2.   attr_reader :color, :previous, :next
  3.  
  4.   def initialize(color)
  5.     @color = color
  6.     @previous = nil
  7.     @next = nil
  8.   end
  9.  
  10.   def link_to(color)
  11.     @next = color
  12.     color.link_from(self) if color.previous != self
  13.     color
  14.   end
  15.  
  16.   def link_from(color)
  17.     @previous = color
  18.     color.link_to(self) if color.next != self
  19.     color
  20.   end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement