Class: Jschematic::Attributes::ExclusiveMinimum

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/jschematic/attributes/exclusive_minimum.rb

Instance Attribute Summary

Attributes included from Element

#id, #parent

Instance Method Summary collapse

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

Returns:

  • (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