Йончо обнови решението на 27.10.2014 12:08 (преди около 10 години)
+require 'enumerator'
+require 'Rational'
+require 'Complex'
+
+
+class Filter
+ def initialize
+ @list_numbers = []
+ end
+end
+
+class TypeFilter
+ # :integer, :real :complex
+ def initialize
+ @list_numbers = []
+ end
+end
+
+
+class SignFilter
+ # :positive, :non_positive, :negative , :non_negative
+ def initialize
+ @list_numbers = []
+ end
+end
+
+class NumberSet
+ include Enumerable, Comparable
+
+ attr_reader :list_numbers
+
+ def << element
+ if element.respond_to? :to_c
+ if ! list_numbers.include?(element)
+ @list_numbers.push element.to_c
+ end
+ else
+ raise "Not a number."
+ end
+ end
+
+ def <=>(other)
+ str.to_c <=> other.str.to_c
+ end
+
+ def size
+ return @list_numbers.size()
+ end
+
+ def empty?
+ return @list_numbers.empty?()
+ end
+
+ def each
+ @list_numbers.each { |i| yield i }
+ end
+
+ def initialize
+ @list_numbers = []
+ end
+
+ def include? element
+ @list_numbers.each do |i|
+ if i == element then true
+ end
+ end
+ return false
+ end
+
+ def []
+ end
+end
Първа итерация, реализиран само клас NumberSet без филтрите.