Class: ParameterSubstitution::Formatters::SplitAndFind

Inherits:
Base
  • Object
show all
Defined in:
lib/parameter_substitution/formatters/split_and_find.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

encoding, format, key, parse_duration

Constructor Details

#initialize(delimiter, index) ⇒ SplitAndFind

Returns a new instance of SplitAndFind.



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

def initialize(delimiter, index)
  @delimiter = delimiter
  @index = index
end

Class Method Details

.descriptionObject



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

def self.description
  "Takes delimiter and index as arguments. Splits the input on delimiters and returns the indexed element. Preserves nil."
end

.has_parameters?Boolean

Returns:

  • (Boolean)


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

def self.has_parameters?
  true
end

Instance Method Details

#format(value) ⇒ Object



17
18
19
# File 'lib/parameter_substitution/formatters/split_and_find.rb', line 17

def format(value)
  value && value.to_s.split(@delimiter)[@index]
end