Module: Linguo

Defined in:
lib/linguo.rb,
lib/linguo/config.rb,
lib/linguo/detect.rb,
lib/linguo/errors.rb,
lib/linguo/version.rb,
lib/rails/generators/linguo/config_generator.rb

Defined Under Namespace

Modules: Config, Errors Classes: ConfigGenerator, Detect

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.api_key=(val) ⇒ Object

Sets API key obtained from detectlanguage.com.

See Also:



13
14
15
# File 'lib/linguo.rb', line 13

def self.api_key=(val)
  Config.api_key = val
end

.detect(text, api_key = nil) ⇒ Linguo::Detect

Creates a new instance of Linguo::Detect.

Note that api_key is optional and isn’t required once you set Linguo::Config.api_key or ENV['LINGUO_API_KEY'].

Parameters:

  • text (String)

    The text required to detect.

  • api_key (String) (defaults to: nil)

    The API key obtained from detectlanguage.com.

Returns:



25
26
27
28
# File 'lib/linguo.rb', line 25

def self.detect(text, api_key=nil)
  api_key = api_key || Linguo::Config.api_key || ENV['LINGUO_API_KEY']
  Detect.new(text, api_key)
end