Class: Attributor::Float
- Inherits:
-
Object
- Object
- Attributor::Float
- Includes:
- Type
- Defined in:
- lib/attributor/types/float.rb
Class Method Summary collapse
- .example(_context = nil, options: {}) ⇒ Object
- .family ⇒ Object
- .load(value, context = Attributor::DEFAULT_ROOT_CONTEXT, **options) ⇒ Object
- .native_type ⇒ Object
Methods included from Type
Class Method Details
.example(_context = nil, options: {}) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/attributor/types/float.rb', line 12 def self.example(_context = nil, options: {}) min = [:min].to_f || 0.0 max = [:max].to_f || Math.PI rand * (max - min) + min end |
.family ⇒ Object
25 26 27 |
# File 'lib/attributor/types/float.rb', line 25 def self.family 'numeric' end |
.load(value, context = Attributor::DEFAULT_ROOT_CONTEXT, **options) ⇒ Object
19 20 21 22 23 |
# File 'lib/attributor/types/float.rb', line 19 def self.load(value, context = Attributor::DEFAULT_ROOT_CONTEXT, **) Float(value) rescue TypeError super end |
.native_type ⇒ Object
8 9 10 |
# File 'lib/attributor/types/float.rb', line 8 def self.native_type ::Float end |