Class: ParameterSubstitution::Formatters::DateTimeStrftime

Inherits:
DateTimeFormat show all
Defined in:
lib/parameter_substitution/formatters/date_time_strftime.rb

Constant Summary

Constants inherited from DateTimeFormat

ParameterSubstitution::Formatters::DateTimeFormat::MINIMUM_INTEGER_TIME

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DateTimeFormat

from_custom_time, from_parse, from_unix_time_ms, from_unix_time_sec, from_yyyymmddhhmmssss, parse_to_time

Methods inherited from Base

encoding, format, key, parse_duration

Constructor Details

#initialize(formatting_string) ⇒ DateTimeStrftime

Returns a new instance of DateTimeStrftime.



12
13
14
# File 'lib/parameter_substitution/formatters/date_time_strftime.rb', line 12

def initialize(formatting_string)
  @formatting_string = formatting_string
end

Class Method Details

.descriptionObject



8
9
10
# File 'lib/parameter_substitution/formatters/date_time_strftime.rb', line 8

def self.description
  "Formats a DateTime with the provided format string."
end

.has_parameters?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/parameter_substitution/formatters/date_time_strftime.rb', line 4

def self.has_parameters?
  true
end

Instance Method Details

#format(value) ⇒ Object



16
17
18
# File 'lib/parameter_substitution/formatters/date_time_strftime.rb', line 16

def format(value)
  self.class.parse_to_time(value)&.strftime(@formatting_string).to_s
end