Class: Shogun::Verifier::Range
- Inherits:
-
Object
- Object
- Shogun::Verifier::Range
- Defined in:
- lib/shogun/verifier/range.rb
Instance Method Summary collapse
- #context ⇒ Object
- #id ⇒ Object
-
#initialize(name:, data:, range:) ⇒ Range
constructor
A new instance of Range.
- #valid? ⇒ Boolean
Constructor Details
#initialize(name:, data:, range:) ⇒ Range
Returns a new instance of Range.
4 5 6 7 8 |
# File 'lib/shogun/verifier/range.rb', line 4 def initialize(name:, data:, range:) @data = data @name = name @range = range end |
Instance Method Details
#context ⇒ Object
22 23 24 25 26 27 |
# File 'lib/shogun/verifier/range.rb', line 22 def context { "maximum" => @range.max, "minimum" => @range.min } end |
#id ⇒ Object
18 19 20 |
# File 'lib/shogun/verifier/range.rb', line 18 def id "#{@name}_was_out_of_range" end |
#valid? ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/shogun/verifier/range.rb', line 10 def valid? if @data.is_a?(String) @range.cover?(@data.size) else @range.cover?(@data) end end |