Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Color
- attr_reader :color, :previous, :next
- def initialize(color)
- @color = color
- @previous = nil
- @next = nil
- end
- def link_to(color)
- @next = color
- color.link_from(self) if color.previous != self
- color
- end
- def link_from(color)
- @previous = color
- color.link_to(self) if color.next != self
- color
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement