1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
class Interval def initialize(min = Float::INFINITY, max = -Float::INFINITY) @min = min @max = max end attr_reader :min, :max def size @max - @min end def include?(x) min <= x && x <= max end def surround?(x) min < x && x < max end end