Sha256: e18ff758f8da79ceb4298f0891c0f75ce55253c485222781d277d82f9265665c

Contents?: true

Size: 581 Bytes

Versions: 7

Compression:

Stored size: 581 Bytes

Contents

require "cld/version"
require "ffi"

module CLD
  extend FFI::Library

  def self.detect_language(text, is_plain_text=true)
    result = detect_language_ext(text.to_s, is_plain_text)
    Hash[ result.members.map {|member| [member.to_sym, result[member]]} ]
  end

  private

  class ReturnValue < FFI::Struct
    layout :name, :string, :code, :string, :reliable, :bool
  end

  GEM_ROOT = File.expand_path("../../", __FILE__)
  ffi_lib "#{GEM_ROOT}/ext/cld/lib/cld.so"
  attach_function "detect_language_ext","detectLanguageThunkInt", [:buffer_in, :bool], ReturnValue.by_value
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
cld-0.13.0 lib/cld.rb
cld-0.12.0 lib/cld.rb
cld-0.11.0 lib/cld.rb
cld-0.10.0 lib/cld.rb
cld-0.8.0 lib/cld.rb
cld-fixed-0.7.1 lib/cld.rb
cld-0.7.0 lib/cld.rb