Class: Jschematic::Attributes::Maximum
- Inherits:
-
Object
- Object
- Jschematic::Attributes::Maximum
- Includes:
- Element
- Defined in:
- lib/jschematic/attributes/maximum.rb
Instance Attribute Summary collapse
-
#maximum ⇒ Object
readonly
Returns the value of attribute maximum.
Attributes included from Element
Instance Method Summary collapse
- #accepts?(number) ⇒ Boolean
-
#initialize(maximum) ⇒ Maximum
constructor
A new instance of Maximum.
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
#maximum ⇒ Object (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
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 |