Sha256: eafd9489cec9b1bebe5d6f4bb05b06eba2c043f196ecf95e95c53b5e2f3c4d63
Contents?: true
Size: 771 Bytes
Versions: 12
Compression:
Stored size: 771 Bytes
Contents
module Taskinator class Tasks include Enumerable # implements a linked list, where each task references the next task attr_reader :head alias_method :first, :head def initialize(first=nil) @head = first end def add(task) if @head.nil? @head = task else current = @head while current.next current = current.next end current.next = task end task end alias_method :<<, :add alias_method :push, :add def empty? @head.nil? end def each(&block) return to_enum(__method__) unless block_given? current = @head while current != nil yield current current = current.next end end end end
Version data entries
12 entries across 12 versions & 1 rubygems