Class: Hermod::Validators::Range

Inherits:
Base
  • Object
show all
Defined in:
lib/hermod/validators/range.rb

Overview

Checks a value is in the given range

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#valid?

Constructor Details

#initialize(range_or_min, max = nil) ⇒ Range

Returns a new instance of Range.



9
10
11
12
13
14
15
# File 'lib/hermod/validators/range.rb', line 9

def initialize(range_or_min, max = nil)
  if max
    @range = range_or_min..max
  else
    @range = range_or_min
  end
end

Instance Attribute Details

#rangeObject (readonly)

Returns the value of attribute range.



7
8
9
# File 'lib/hermod/validators/range.rb', line 7

def range
  @range
end