Module: GoogleSpellChecker

Defined in:
lib/google_spell_checker.rb,
lib/google_spell_checker/config.rb,
lib/google_spell_checker/version.rb,
lib/generators/google_spell_checker/config_generator.rb

Defined Under Namespace

Modules: Generators Classes: Configuration

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.check(content) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/google_spell_checker.rb', line 5

def self.check content
  check_using_hk?
  params = {:q=> content, :oq=> content}
  uri = URI(@base)
  uri.query = URI.encode_www_form(params)
  res = Net::HTTP.get(uri)
  matches = res.to_enum(:scan,@regex).map{Regexp.last_match}
  matches[0,(matches.count/2)].inject(""){|result,match|result + match.to_s}
end

.configObject



9
10
11
# File 'lib/google_spell_checker/config.rb', line 9

def self.config 
  @config 
end

.configure {|@config ||= GoogleSpellChecker::Configuration.new| ... } ⇒ Object



5
6
7
# File 'lib/google_spell_checker/config.rb', line 5

def self.configure(&block)
  yield @config ||= GoogleSpellChecker::Configuration.new
end

Instance Method Details

#param_nameObject



18
19
20
# File 'lib/google_spell_checker/config.rb', line 18

def param_name
  config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
end