Class: NameQ::Support::Suffix
- Inherits:
-
Object
- Object
- NameQ::Support::Suffix
- Defined in:
- lib/nameq/support/suffix.rb
Constant Summary collapse
- TOKEN =
'%{index}'
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
-
#initialize(index, template: nil) ⇒ Suffix
constructor
A new instance of Suffix.
- #strip(text) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(index, template: nil) ⇒ Suffix
Returns a new instance of Suffix.
8 9 10 11 |
# File 'lib/nameq/support/suffix.rb', line 8 def initialize(index, template: nil) @index = index @template = template || " (#{TOKEN})" end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/nameq/support/suffix.rb', line 6 def index @index end |
Instance Method Details
#strip(text) ⇒ Object
13 14 15 |
# File 'lib/nameq/support/suffix.rb', line 13 def strip(text) text.sub(regex, '') end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/nameq/support/suffix.rb', line 17 def to_s @template % {index: index} end |