Class: Jschematic::Attributes::ExclusiveMinimum
- Inherits:
-
Object
- Object
- Jschematic::Attributes::ExclusiveMinimum
- Includes:
- Element
- Defined in:
- lib/jschematic/attributes/exclusive_minimum.rb
Instance Attribute Summary
Attributes included from Element
Instance Method Summary collapse
- #accepts?(actual) ⇒ Boolean
-
#initialize(enabled, &block) ⇒ ExclusiveMinimum
constructor
A new instance of ExclusiveMinimum.
Methods included from Element
#required?, #schema_for, #title, #to_s
Constructor Details
#initialize(enabled, &block) ⇒ ExclusiveMinimum
Returns a new instance of ExclusiveMinimum.
8 9 10 11 12 |
# File 'lib/jschematic/attributes/exclusive_minimum.rb', line 8 def initialize(enabled, &block) @enabled = enabled @minimum = block.call("minimum") if block_given? raise "'exclusiveMinimum' depends on 'minimum'" unless @minimum end |
Instance Method Details
#accepts?(actual) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/jschematic/attributes/exclusive_minimum.rb', line 14 def accepts?(actual) if @enabled (actual > @minimum) || fail_validation!("> #{@minimum}", actual) end end |