Class: Hasta::InterpolateString

Inherits:
Object
  • Object
show all
Defined in:
lib/hasta/interpolate_string.rb

Overview

Interpolates scheduled start time expressions in S3 path strings

Constant Summary collapse

INTERPOLATE_PATTERN =
/\#\{format\(@scheduledStartTime,'(.*?)'\)\}/
PATTERN_CONVERSIONS =
{
  'YYYY' => '%Y',
  'MM' => '%m',
  'dd' => '%d',
  'HH' => '%H',
  'mm' => '%M',
  'ss' => '%S',
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ InterpolateString

Returns a new instance of InterpolateString.



21
22
23
# File 'lib/hasta/interpolate_string.rb', line 21

def initialize(pattern)
  @pattern = pattern
end

Class Method Details

.evaluate(pattern, context) ⇒ Object



17
18
19
# File 'lib/hasta/interpolate_string.rb', line 17

def self.evaluate(pattern, context)
  new(pattern).evaluate(context)
end

Instance Method Details

#evaluate(context) ⇒ Object



25
26
27
28
29
# File 'lib/hasta/interpolate_string.rb', line 25

def evaluate(context)
  pattern.gsub(INTERPOLATE_PATTERN) do |match|
    format(context, Regexp.last_match[1])
  end
end