lib/active_object/range.rb in active_object-1.4.0 vs lib/active_object/range.rb in active_object-2.0.0

- old
+ new

@@ -1,20 +1,36 @@ class Range + def combine(other) + to_a.concat(other.to_a) + end + unless defined?(Rails) - def include_with_range?(value) - if value.is_a?(::Range) - operator = exclude_end? && !value.exclude_end? ? :< : :<= - include?(value.first) && value.last.send(operator, last) + def include_with_range?(other) + if other.is_a?(::Range) + operator = exclude_end? && !other.exclude_end? ? :< : :<= + include?(other.first) && other.last.send(operator, last) else - include?(value) + include?(other) end end end unless defined?(Rails) def overlaps?(other) cover?(other.first) || other.cover?(first) end + end + + def sample + to_a.sample + end + + def shuffle + to_a.shuffle + end + + def within?(other) + cover?(other.first) && cover?(other.last) end end \ No newline at end of file