Class: NameQ::Support::Suffix

Inherits:
Object
  • Object
show all
Defined in:
lib/nameq/support/suffix.rb

Constant Summary collapse

TOKEN =
'%{index}'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#indexObject (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_sObject



17
18
19
# File 'lib/nameq/support/suffix.rb', line 17

def to_s
  @template % {index: index}
end