Class: Compendium::DateParam

Inherits:
Param
  • Object
show all
Defined in:
lib/compendium/param_types.rb

Instance Method Summary collapse

Methods inherited from Param

#==, #boolean?, #dropdown?, #nil?, #radio?, #scalar?

Constructor Details

#initialize(obj) ⇒ DateParam

Returns a new instance of DateParam.



77
78
79
80
81
82
83
84
85
# File 'lib/compendium/param_types.rb', line 77

def initialize(obj, *)
  if obj.respond_to?(:to_date)
    obj = obj.to_date
  else
    obj = Date.parse(obj) rescue nil
  end

  super obj
end

Instance Method Details

#date?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/compendium/param_types.rb', line 87

def date?
  true
end