Class: ParameterSubstitution::Formatters::Mid

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

encoding, format, key, parse_duration

Constructor Details

#initialize(starting_position, character_count) ⇒ Mid

Returns a new instance of Mid.



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

def initialize(starting_position, character_count)
  @starting_position = starting_position
  @character_count = character_count
end

Class Method Details

.descriptionObject



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

def self.description
  "Takes starting_position and character_count as arguments. Returns the character_count characters starting from starting_position from the input."
end

.has_parameters?Boolean

Returns:

  • (Boolean)


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

def self.has_parameters?
  true
end

Instance Method Details

#format(value) ⇒ Object



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

def format(value)
  value.to_s[@starting_position, @character_count]
end