Sha256: 8d638e14519e534355e1182ce9422f3dfe802984748fc0564fde3e3a79c9280f

Contents?: true

Size: 868 Bytes

Versions: 2

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true

class String
  # Return the string replaced similar-looking chars randomly.
  #
  #     'リリリリリリリリリン'.typo
  #     # => "ソリンッリリリッンソ"
  #
  # Setting <tt>frequency: 0</tt> disables typo. Default value is <tt>0.5</tt>.
  #
  #     'リリリリリリリリリン'.typo(frequency: 0)
  #     # => "リリリリリリリリリン"
  #
  #     'リリリリリリリリリン'.typo(frequency: 1.0)
  #     # => "ソソンッソソソッンリ"
  def typo(options = {})
    Masososo.similar_string(self, options)
  end
  alias masososo typo

  # Returns similar chars.
  #
  #     'ソ'.similar_chars
  #     # => ["リ", "ン"]
  #
  #     'ソ'.similar_chars(including_self: true)
  #     # => ["ソ", "リ", "ン"]
  def similar_chars(options = {})
    Masososo.similar_chars(self, options)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
masososo-0.0.3 lib/masososo/core_ext.rb
masososo-0.0.2 lib/masososo/core_ext.rb