Module: Sequel::Extensions::MoreThan
- Defined in:
- lib/sequel/extensions/more_than.rb
Instance Method Summary collapse
-
#at_least?(number_of_rows) ⇒ Boolean
Returns true if at least number_of_rows records exist in the dataset, false otherwise.
-
#at_most?(number_of_rows) ⇒ Boolean
Returns true if at most number_of_rows records exist in the dataset, false otherwise.
-
#fewer_than?(number_of_rows) ⇒ Boolean
Returns true if fewer than number_of_rows records exist in the dataset, false otherwise.
-
#more_than?(number_of_rows) ⇒ Boolean
Returns true if more than number_of_rows records exist in the dataset, false otherwise.
Instance Method Details
#at_least?(number_of_rows) ⇒ Boolean
Returns true if at least number_of_rows records exist in the dataset, false otherwise
Equivalent to a “greater than or equal to” (>=) comparison
72 73 74 75 76 77 78 79 |
# File 'lib/sequel/extensions/more_than.rb', line 72 def at_least?(number_of_rows) unless number_of_rows.is_a?(Integer) raise ArgumentError, "`number_of_rows` must be an Integer, got #{number_of_rows.inspect}" end more_than?(number_of_rows - 1) end |
#at_most?(number_of_rows) ⇒ Boolean
Returns true if at most number_of_rows records exist in the dataset, false otherwise
Equivalent to a “less than or equal to” (<=) comparison
88 89 90 |
# File 'lib/sequel/extensions/more_than.rb', line 88 def at_most?(number_of_rows) !more_than?(number_of_rows) end |
#fewer_than?(number_of_rows) ⇒ Boolean
Returns true if fewer than number_of_rows records exist in the dataset, false otherwise
Equivalent to a “less than” (<) comparison
56 57 58 59 60 61 62 63 |
# File 'lib/sequel/extensions/more_than.rb', line 56 def fewer_than?(number_of_rows) unless number_of_rows.is_a?(Integer) raise ArgumentError, "`number_of_rows` must be an Integer, got #{number_of_rows.inspect}" end !more_than?(number_of_rows - 1) end |
#more_than?(number_of_rows) ⇒ Boolean
Returns true if more than number_of_rows records exist in the dataset, false otherwise
Equivalent to a “greater than” (>) comparison
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sequel/extensions/more_than.rb', line 28 def more_than?(number_of_rows) unless number_of_rows.is_a?(Integer) raise ArgumentError, "`number_of_rows` must be an Integer, got #{number_of_rows.inspect}" end if number_of_rows.negative? true elsif number_of_rows.zero? !empty? else ds = @opts[:sql] ? from_self : self !ds .single_value_ds .unordered .offset(number_of_rows) .get(Sequel::SQL::AliasedExpression.new(1, :one)) .nil? end end |