Class: QueryFilter::Utils::DateNormalizer
- Inherits:
-
Object
- Object
- QueryFilter::Utils::DateNormalizer
- Defined in:
- lib/query_filter/utils/date_normalizer.rb
Constant Summary collapse
- PG_MIN_YEAR =
-4713- PG_MAX_YEAR =
294_276
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
-
#initialize(date, format = nil) ⇒ DateNormalizer
constructor
A new instance of DateNormalizer.
- #normalize ⇒ Object
- #parsed_value ⇒ Object
Constructor Details
#initialize(date, format = nil) ⇒ DateNormalizer
Returns a new instance of DateNormalizer.
11 12 13 14 |
# File 'lib/query_filter/utils/date_normalizer.rb', line 11 def initialize(date, format = nil) @date = date @format = format end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
9 10 11 |
# File 'lib/query_filter/utils/date_normalizer.rb', line 9 def date @date end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
9 10 11 |
# File 'lib/query_filter/utils/date_normalizer.rb', line 9 def format @format end |
Instance Method Details
#normalize ⇒ Object
20 21 22 |
# File 'lib/query_filter/utils/date_normalizer.rb', line 20 def normalize valid?(parsed_value) ? parsed_value : default_date end |
#parsed_value ⇒ Object
16 17 18 |
# File 'lib/query_filter/utils/date_normalizer.rb', line 16 def parsed_value @parsed_value ||= parse end |