Class: MorseCode::Encoders::Chinese

Inherits:
Base
  • Object
show all
Defined in:
lib/morse_code/encoders/chinese.rb

Instance Attribute Summary

Attributes inherited from Base

#namespace, #word

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, #supported_class, #supported_classes

Constructor Details

This class inherits a constructor from MorseCode::Base

Instance Method Details

#callObject



13
14
15
# File 'lib/morse_code/encoders/chinese.rb', line 13

def call
  word.ord.to_s(2).tr!('0', '.').tr!('1', '-')
end

#supported?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/morse_code/encoders/chinese.rb', line 9

def supported?
  !/\p{Han}/.match(word).nil? # \u4e00-\u9fa5
end