Class: Halation::Coerce
- Inherits:
-
Object
- Object
- Halation::Coerce
- Defined in:
- lib/halation/coerce.rb
Overview
A collection of methods to coerce values into a desired type.
Class Method Summary collapse
Class Method Details
.boolean(value) ⇒ Boolean
16 17 18 |
# File 'lib/halation/coerce.rb', line 16 def self.boolean(value) !!value end |
.date(value) ⇒ Date?
21 22 23 |
# File 'lib/halation/coerce.rb', line 21 def self.date(value) value && Time.parse(value) end |
.integer(value) ⇒ Integer?
11 12 13 |
# File 'lib/halation/coerce.rb', line 11 def self.integer(value) value && value.to_i end |
.string(value) ⇒ String?
6 7 8 |
# File 'lib/halation/coerce.rb', line 6 def self.string(value) value && value.to_s end |