Class: Typero::FloatType
- Defined in:
- lib/typero/type/types/float_type.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Type
Type::ERRORS, Type::OPTS, Type::OPTS_KEYS
Instance Attribute Summary
Attributes inherited from Type
Instance Method Summary collapse
Methods inherited from Type
allowed_opt?, #db_field, db_schema, #default, error, #get, #initialize, load, opts, #value
Constructor Details
This class inherits a constructor from Typero::Type
Instance Method Details
#db_schema ⇒ Object
18 19 20 |
# File 'lib/typero/type/types/float_type.rb', line 18 def db_schema [:float, {}] end |
#set ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/typero/type/types/float_type.rb', line 6 def set @value = if opts[:round] value.to_f.round(opts[:round]) else value.to_f end error_for(:min_value_error, opts[:min], value) if opts[:min] && value < opts[:min] error_for(:max_value_error, opts[:max], value) if opts[:max] && value > opts[:max] end |