Sha256: 360c6079c67c15534abfdeee07f449e32c6fa62a6a2a82eaf0aefbedf2e8d289

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

require 'linguo/version'
require 'linguo/config'
require 'linguo/detect'
require 'linguo/errors'
require 'linguo/core_ext/string'
require 'net/http'
require 'json'

module Linguo
  # Sets API key obtained from detectlanguage.com.
  #
  # @see Linguo::Config
  def self.api_key=(val)
    Config.api_key = val
  end

  # Creates a new instance of Linguo::Detect.
  #
  # Note that api_key is optional and isn't required once you set
  # <tt>Linguo::Config.api_key</tt> or <tt>ENV['LINGUO_API_KEY']</tt>.
  #
  # @param  [String] text The text required to detect.
  # @param  [String] api_key The API key obtained from detectlanguage.com.
  # @return [Linguo::Detect]
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
linguo-0.0.2 lib/linguo.rb
linguo-0.0.1 lib/linguo.rb