Class: WhatYouSay

Inherits:
Object
  • Object
show all
Defined in:
lib/what_you_say.rb,
lib/what_you_say/lang.rb,
lib/what_you_say/version.rb

Defined Under Namespace

Classes: Lang

Constant Summary collapse

VERSION =
"0.6.9"

Instance Method Summary collapse

Instance Method Details

#detect_language(text) ⇒ Object

Raises:

  • (TypeError)


13
14
15
16
17
18
# File 'lib/what_you_say.rb', line 13

def detect_language(text)
  raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
  raise TypeError, "text must be UTF-8 encoded; got #{text.encoding}!" unless text.encoding.name == "UTF-8"

  detect_text(text)
end