Class: Virtus::Coercion::Time

Inherits:
Object show all
Extended by:
TimeCoercions
Defined in:
lib/virtus/coercion/time.rb

Overview

Coerce Time values

Constant Summary

Constants inherited from Object

Object::COERCION_METHOD_REGEXP

Constants included from TypeLookup

TypeLookup::TYPE_FORMAT

Class Method Summary collapse

Methods included from TimeCoercions

to_date, to_datetime, to_string, to_time

Methods inherited from Object

to_array, to_hash, to_string

Methods inherited from Virtus::Coercion

[]

Methods included from DescendantsTracker

#add_descendant, #descendants

Methods included from TypeLookup

#determine_type, extended, #primitive

Methods included from Options

#accept_options, #accepted_options, #options

Class Method Details

.to_integer(value) ⇒ Fixnum

Creates a Fixnum instance from a Time object

Examples:

Virtus::Coercion::Time.to_integer(time)  # => Fixnum object

Parameters:

Returns:

  • (Fixnum)


34
35
36
# File 'lib/virtus/coercion/time.rb', line 34

def self.to_integer(value)
  value.to_i
end

.to_time(value) ⇒ Date

Passthrough the value

Examples:

Virtus::Coercion::DateTime.to_time(time)  # => Time object

Parameters:

Returns:



20
21
22
# File 'lib/virtus/coercion/time.rb', line 20

def self.to_time(value)
  value
end