Skip to content

Instantly share code, notes, and snippets.

@jredville
Forked from mattpodwysocki/test_subscription.rb
Last active August 29, 2015 13:55
Show Gist options
  • Save jredville/8743749 to your computer and use it in GitHub Desktop.
Save jredville/8743749 to your computer and use it in GitHub Desktop.
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
module RX
# Records information about subscriptions to and unsubscriptions from observable sequences.
class TestSubscription < Struct.new(:subscribe, :unsubscribe)
FIXNUM_MAX = (2**(0.size * 8 -2) -1)
def initialize(subscribe, unsubscribe = FIXNUM_MAX)
super
end
def ==(o)
o.class == self.class && subscribe == other.subscribe && unsubscribe == other.unsubscribe
end
alias_method :eql?, :==
def inifinite?
unsubscribe == FIXNUM_MAX
end
def to_s
"#{subscribe}, #{infinite? ? 'Infinite' : unsubscribe}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment