ReactiveX / RxRuby

Reactive Extensions for Ruby

Repository from Github https://github.comReactiveX/RxRubyRepository from Github https://github.comReactiveX/RxRuby

Delay uses non-existing function Math.max

xunningy opened this issue · comments

In the implementation of delay operator, it uses an non-existing function Math.max in Ruby, which yields exception/failure. Please fix the problem. Here is a test program delay_test.rb:

require 'rx'

#uncomment the following lines to see how it could be fixed externally
=begin
module Math
    def self.max(*values)
        values.max
    end
end
=end

subj = RX::Subject.new

subj.map {|_| Time.now}
    .delay(1.0)
    .do( lambda {|t| puts "delayed #{Time.now - t} seconds"; subj.on_next(1) } )
    .publish()
    .connect()

subj.on_next(1)

while Thread.list.size > 1
  (Thread.list - [Thread.current]).each &:join
end

The running results:

delayed 1.004 seconds
NoMethodError: undefined method `max' for Math:Module
                         delay_time_span at D:/Tools/jruby-1.7.19/lib/ruby/gems/
shared/gems/rx-0.0.1/lib/rx/linq/observable/delay.rb:57
                                    call at org/jruby/RubyProc.java:271
             schedule_recursive_relative at D:/Tools/jruby-1.7.19/lib/ruby/gems/
shared/gems/rx-0.0.1/lib/rx/concurrency/scheduler.rb:48
                                    call at org/jruby/RubyProc.java:271
                   invoke_recursive_time at D:/Tools/jruby-1.7.19/lib/ruby/gems/
shared/gems/rx-0.0.1/lib/rx/concurrency/scheduler.rb:133
                                    call at org/jruby/RubyProc.java:271
                   invoke_recursive_time at D:/Tools/jruby-1.7.19/lib/ruby/gems/
shared/gems/rx-0.0.1/lib/rx/concurrency/scheduler.rb:159
  schedule_recursive_relative_with_state at D:/Tools/jruby-1.7.19/lib/ruby/gems/
shared/gems/rx-0.0.1/lib/rx/concurrency/scheduler.rb:57
                                    call at org/jruby/RubyProc.java:271
            schedule_relative_with_state at D:/Tools/jruby-1.7.19/lib/ruby/gems/
shared/gems/rx-0.0.1/lib/rx/concurrency/default_scheduler.rb:44