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