Class: ParameterSubstitution::Formatters::Right
- Inherits:
-
Base
- Object
- Base
- ParameterSubstitution::Formatters::Right
show all
- Defined in:
- lib/parameter_substitution/formatters/right.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
encoding, format, key, parse_duration
Constructor Details
#initialize(character_count) ⇒ Right
Returns a new instance of Right.
12
13
14
|
# File 'lib/parameter_substitution/formatters/right.rb', line 12
def initialize(character_count)
@character_count = character_count
end
|
Class Method Details
.description ⇒ Object
4
5
6
|
# File 'lib/parameter_substitution/formatters/right.rb', line 4
def self.description
"Takes a single n argument. Returns the right most n characters from the input."
end
|
.has_parameters? ⇒ Boolean
8
9
10
|
# File 'lib/parameter_substitution/formatters/right.rb', line 8
def self.has_parameters?
true
end
|
Instance Method Details
16
17
18
19
20
21
22
|
# File 'lib/parameter_substitution/formatters/right.rb', line 16
def format(value)
if (as_string = value.to_s).size > @character_count
as_string[-@character_count, @character_count]
else
as_string
end
end
|