mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
15 lines
490 B
Ruby
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
|