Class: Sawarineko::Converter

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

Overview

Convert plain text to Sawarineko text.

Instance Method Summary collapse

Instance Method Details

#convert(source) ⇒ Object

Convert the source.

source - The String source to convert.

Returns the String converted to Sawarineko.



11
12
13
14
15
16
# File 'lib/sawarineko/converter.rb', line 11

def convert(source)
  source
    .gsub(//, 'にゃ')
    .gsub(//, 'ニャ')
    .gsub(/[나-낳]/) { |ch| (ch.ord + 56).chr(Encoding::UTF_8) }
end