Class: TableWarnings::Range
- Defined in:
- lib/table_warnings/range.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Attributes inherited from Exclusive
Instance Method Summary collapse
-
#initialize(table, matcher, options = {}) ⇒ Range
constructor
A new instance of Range.
- #message(column) ⇒ Object
Methods inherited from Exclusive
#covers, #exclusives, #matches, #messages
Constructor Details
#initialize(table, matcher, options = {}) ⇒ Range
Returns a new instance of Range.
6 7 8 9 10 11 12 13 14 |
# File 'lib/table_warnings/range.rb', line 6 def initialize(table, matcher, = {}) super @min = [:min] @max = [:max] @allow_null_query = [:allow_null] if min and max and min > max raise ArgumentError, "Min #{min.inspect} must be less than max #{max.inspect}" end end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
3 4 5 |
# File 'lib/table_warnings/range.rb', line 3 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
4 5 6 |
# File 'lib/table_warnings/range.rb', line 4 def min @min end |
Instance Method Details
#message(column) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/table_warnings/range.rb', line 16 def (column) if column.values_outside?(min, max, conditions) or (not allow_null? and column.nulls?(conditions)) if conditions.empty? "Unexpected range for #{column.name.inspect}. Min: #{column.min.inspect} (expected #{min.inspect}) Max: #{column.max.inspect} (expected #{max.inspect})" else "Unexpected range for #{column.name.inspect} in #{conditions.inspect}. Min: #{column.min.inspect} (expected #{min.inspect}) Max: #{column.max.inspect} (expected #{max.expect})" end end end |