Class: Jschematic::Attributes::Maximum

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/jschematic/attributes/maximum.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(maximum) ⇒ Maximum

Returns a new instance of Maximum.



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

def initialize(maximum)
  @maximum = maximum
end

Instance Attribute Details

#maximumObject (readonly)

Returns the value of attribute maximum.



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

def maximum
  @maximum
end

Instance Method Details

#accepts?(number) ⇒ Boolean

Returns:

  • (Boolean)


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

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

  (number <= maximum) || fail_validation!("<= #{@maximum}", number)
end