Class: Coercible::Coercer::Time

Inherits:
Object
  • Object
show all
Includes:
TimeCoercions
Defined in:
lib/coercible/coercer/time.rb

Overview

Coerce Time values

Constant Summary

Constants inherited from Object

Object::COERCION_METHOD_REGEXP

Constants included from Options

Options::Undefined

Constants included from TypeLookup

TypeLookup::TYPE_FORMAT

Instance Attribute Summary

Attributes inherited from Object

#coercers

Instance Method Summary collapse

Methods included from TimeCoercions

#to_date, #to_datetime, #to_string

Methods inherited from Object

#coerced?, #initialize, #inspect, #to_array, #to_hash, #to_string

Methods included from Options

#accept_options, #accepted_options, extended, #options

Methods included from TypeLookup

#determine_type, extended, #primitive

Constructor Details

This class inherits a constructor from Coercible::Coercer::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Coercible::Coercer::Object

Instance Method Details

#to_integer(value) ⇒ Fixnum

Creates a Fixnum instance from a Time object

Examples:

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

Parameters:

Returns:

  • (Fixnum)


34
35
36
# File 'lib/coercible/coercer/time.rb', line 34

def to_integer(value)
  value.to_i
end

#to_time(value) ⇒ Date

Passthrough the value

Examples:

coercer[DateTime].to_time(time)  # => Time object

Parameters:

Returns:



20
21
22
# File 'lib/coercible/coercer/time.rb', line 20

def to_time(value)
  value
end