Class: MorseCode::Encoders::Chinese
- Defined in:
- lib/morse_code/encoders/chinese.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
inherited, #initialize, #supported_class
Constructor Details
This class inherits a constructor from MorseCode::Encoders::Base
Instance Method Details
#encode ⇒ Object
12 13 14 |
# File 'lib/morse_code/encoders/chinese.rb', line 12 def encode word.ord.to_s(2).gsub!('0', '.').gsub!('1', '-') end |
#supported? ⇒ Boolean
8 9 10 |
# File 'lib/morse_code/encoders/chinese.rb', line 8 def supported? !/\p{Han}/.match(word).nil? # \u4e00-\u9fa5 end |