Class: Treat::Loaders::Linguistics

Inherits:
Object
  • Object
show all
Defined in:
lib/treat/loaders/linguistics.rb

Overview

A helper class to load a language class registered with the Linguistics gem, for example Linguistics::EN.

Constant Summary collapse

@@languages =

Linguistics classes for each language.

{}

Class Method Summary collapse

Class Method Details

.load(language) ⇒ Object

Load the Linguistics class that corresponds to the supplied language; raises an exception if there is no such language class registered.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/treat/loaders/linguistics.rb', line 12

def self.load(language)
  code = language.to_s[0..1].intern # FIX
  unless @@languages[language]
    require 'linguistics'
    Linguistics.use(code)
    @@languages[language] = true
  end
  code
rescue RuntimeError
  raise Treat::Exception,
  "Ruby Linguistics does not have a module " +
  "installed for the #{language} language."
end