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?, #to_f, #to_i

Constructor Details

#initialize(obj) ⇒ DateParam

Returns a new instance of DateParam.



85
86
87
88
89
90
91
92
93
# File 'lib/compendium/param_types.rb', line 85

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)


95
96
97
# File 'lib/compendium/param_types.rb', line 95

def date?
  true
end