Class: Jschematic::Attributes::Minimum

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

Instance Attribute Summary collapse

Attributes included from Element

#id, #parent

Instance Method Summary collapse

Methods included from Element

#required?, #schema_for, #title, #to_s

Constructor Details

#initialize(minimum) ⇒ Minimum

Returns a new instance of Minimum.



10
11
12
# File 'lib/jschematic/attributes/minimum.rb', line 10

def initialize(minimum)
  @minimum = minimum
end

Instance Attribute Details

#minimumObject (readonly)

Returns the value of attribute minimum.



8
9
10
# File 'lib/jschematic/attributes/minimum.rb', line 8

def minimum
  @minimum
end

Instance Method Details

#accepts?(number) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/jschematic/attributes/minimum.rb', line 14

def accepts?(number)
  return true unless Numeric === number

  (number >= minimum) || fail_validation!(">= #{@minimum}", number)
end