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