1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/core/random/fixtures/classes.rb
2019-07-27 12:40:09 +02:00

15 lines
490 B
Ruby

module RandomSpecs
CustomRangeInteger = Struct.new(:value) do
def to_int; value; end
def <=>(other); to_int <=> other.to_int; end
def -(other); self.class.new(to_int - other.to_int); end
def +(other); self.class.new(to_int + other.to_int); end
end
CustomRangeFloat = Struct.new(:value) do
def to_f; value; end
def <=>(other); to_f <=> other.to_f; end
def -(other); to_f - other.to_f; end
def +(other); self.class.new(to_f + other.to_f); end
end
end