Module: Coercible::Coercer::TimeCoercions
Overview
Common time coercion methods
Instance Method Summary collapse
-
#to_date(value) ⇒ Date
Coerce given value to Date.
-
#to_datetime(value) ⇒ DateTime
Coerce given value to DateTime.
-
#to_string(value) ⇒ String
Coerce given value to String.
-
#to_time(value) ⇒ Time
Coerce given value to Time.
Instance Method Details
#to_date(value) ⇒ Date
Coerce given value to Date
59 60 61 |
# File 'lib/coercible/coercer/time_coercions.rb', line 59 def to_date(value) coerce_with_method(value, :to_date) end |
#to_datetime(value) ⇒ DateTime
Coerce given value to DateTime
45 46 47 |
# File 'lib/coercible/coercer/time_coercions.rb', line 45 def to_datetime(value) coerce_with_method(value, :to_datetime) end |
#to_string(value) ⇒ String
Coerce given value to String
17 18 19 |
# File 'lib/coercible/coercer/time_coercions.rb', line 17 def to_string(value) value.to_s end |
#to_time(value) ⇒ Time
Coerce given value to Time
31 32 33 |
# File 'lib/coercible/coercer/time_coercions.rb', line 31 def to_time(value) coerce_with_method(value, :to_time) end |