Coercible::Coercer::Hash

Coerce Hash values

Constants

TIME_SEGMENTS

Public Instance Methods

to_date(value) click to toggle source

Creates a Date instance from a Hash

Valid keys are: :year, :month, :day, :hour

@param [Hash] value

@return [Date]

@api private

# File lib/coercible/coercer/hash.rb, line 32
def to_date(value)
  ::Date.new(*extract(value).first(3))
end
to_datetime(value) click to toggle source

Creates a DateTime instance from a Hash

Valid keys are: :year, :month, :day, :hour, :min, :sec

@param [Hash] value

@return [DateTime]

@api private

# File lib/coercible/coercer/hash.rb, line 45
def to_datetime(value)
  ::DateTime.new(*extract(value))
end
to_time(value) click to toggle source

Creates a Time instance from a Hash

Valid keys are: :year, :month, :day, :hour, :min, :sec

@param [Hash] value

@return [Time]

@api private

# File lib/coercible/coercer/hash.rb, line 19
def to_time(value)
  ::Time.local(*extract(value))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.