Method: Helper.to_unprintable_words

Defined in:
lib/helper.rb

.to_unprintable_words(string, mask = "●") ⇒ Object

伏せ字にする

数字やスペース、句読点、感嘆符はそのままにする



298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/helper.rb', line 298

def to_unprintable_words(string, mask = "")
  result = ""
  string.each_char do |char|
    result += case char
              when /[0-90-9  、。!?!?]/
                char
              else
                mask
              end
  end
  result
end