Class: StringMasker

Inherits:
Object
  • Object
show all
Defined in:
lib/string_masker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, params) ⇒ StringMasker

Returns a new instance of StringMasker.



4
5
6
7
8
9
10
11
12
# File 'lib/string_masker.rb', line 4

def initialize(string, params)
  output_string = string.dup
  
  params.each do |key, value|
    output_string.gsub!(value, "[#{key}]")
  end
  
  @output_string = output_string
end

Instance Attribute Details

#output_stringObject

Returns the value of attribute output_string.



2
3
4
# File 'lib/string_masker.rb', line 2

def output_string
  @output_string
end

#paramsObject

Returns the value of attribute params.



2
3
4
# File 'lib/string_masker.rb', line 2

def params
  @params
end

#stringObject

Returns the value of attribute string.



2
3
4
# File 'lib/string_masker.rb', line 2

def string
  @string
end

Instance Method Details

#to_sObject



14
15
16
# File 'lib/string_masker.rb', line 14

def to_s
  output_string
end