Sha256: 4b7a6c18c329b49293871e7d3155c66240414344f4baaf79613e5ffe59372b3a

Contents?: true

Size: 462 Bytes

Versions: 2

Compression:

Stored size: 462 Bytes

Contents

class String
  # Retrieves all the languages detected for the current string
  # sorted by confidence.
  #
  # Requires <tt>Linguo::Config.api_key</tt> or <tt>ENV['LINGUO_API_KEY']</tt>
  # to be set up.
  #
  # @example
  #  "simple text".lang # => ["en", "fr"]
  # @return [Array]
  def lang
    l ||= Linguo.detect(self, Linguo::Config.api_key)
    l.detections.map {|x| x['language']}
  rescue => e
    raise Linguo::Errors::LinguoError, e.message
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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