Module: Validations::Predicates::Dates::Methods

Included in:
Validations::Predicates::Dates
Defined in:
lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/validations/predicates/dates.rb

Instance Method Summary collapse

Instance Method Details

#earlier_then?(v1, v2) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/validations/predicates/dates.rb', line 13

def earlier_then?(v1, v2)
  v1 && v2 && ::Rich::Date.safe_parse(v1) > ::Rich::Date.safe_parse(v2)
end

#in_future?(value) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/validations/predicates/dates.rb', line 9

def in_future?(value)
  !self[:in_past?].call(value)
end

#in_past?(value) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/validations/predicates/dates.rb', line 5

def in_past?(value)
  value && ::Rich::Date.safe_parse(value).try(:past?)
end

#on_or_later_then?(v1, v2) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/validations/predicates/dates.rb', line 17

def on_or_later_then?(v1, v2)
  !self[:earlier_then?].call(v1, v2)
end

#parsed_as_date?(value) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/endpoint_flux/tasks/endpoint_flux/generators/endpoint_flux/validations/predicates/dates.rb', line 21

def parsed_as_date?(value)
  value.nil? || !Validations::Types::Form::DateTime[value].is_a?(String)
end