Решение на Втора задача от Боян Дончев

Обратно към всички решения

Към профила на Боян Дончев

Резултати

  • 0 точки от тестове
  • 0 бонус точки
  • 0 точки общо
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)

Код

class NumberSet
include Enumerable
include Filters
def initialize
@numbers = []
end
def <<(number)
check = number.to_i
if @numbers.include? check == false
@numbers.push(number)
end
end
def size
@size = @numbers.length
end
def empty?
@size == 0
end
def [](*filters, array_for_filter)
case filters
when filters == "Filter" then Filter(array_for_filter)
when filters == "Type Filter" then Type_Filter(array_for_filter)
when filters == "Sign Filter" then Sign_Filter(array_for_filter)
end
end
def each
@numbers.each {|number| yield number}
end
end

Лог от изпълнението

/tmp/d20141028-18133-14bfpwf/solution.rb:3:in `<class:NumberSet>': uninitialized constant NumberSet::Filters (NameError)
	from /tmp/d20141028-18133-14bfpwf/solution.rb:1:in `<top (required)>'
	from /data/rails/evans-2014/shared/bundle/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:867:in `require'
	from /data/rails/evans-2014/shared/bundle/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:867:in `block in setup_load_path_and_require'
	from /data/rails/evans-2014/shared/bundle/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:867:in `each'
	from /data/rails/evans-2014/shared/bundle/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:867:in `setup_load_path_and_require'
	from /data/rails/evans-2014/shared/bundle/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/configuration_options.rb:25:in `configure'
	from /data/rails/evans-2014/shared/bundle/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:21:in `run'
	from /data/rails/evans-2014/shared/bundle/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run'
	from /data/rails/evans-2014/shared/bundle/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun'

История (1 версия и 0 коментара)

Боян обнови решението на 27.10.2014 16:58 (преди около 10 години)

+class NumberSet
+ include Enumerable
+ include Filters
+
+ def initialize
+ @numbers = []
+ end
+
+ def <<(number)
+ check = number.to_i
+ if @numbers.include? check == false
+ @numbers.push(number)
+ end
+ end
+
+ def size
+ @size = @numbers.length
+ end
+
+ def empty?
+ @size == 0
+ end
+
+ def [](*filters, array_for_filter)
+ case filters
+ when filters == "Filter" then Filter(array_for_filter)
+ when filters == "Type Filter" then Type_Filter(array_for_filter)
+ when filters == "Sign Filter" then Sign_Filter(array_for_filter)
+ end
+ end
+
+ def each
+ @numbers.each {|number| yield number}
+ end
+
+end
+