Class: AlfonsoX::SpellChecker::Dictionary::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/alfonsox/spellchecker/dictionary/default.rb

Overview

Default dictionary loader

Constant Summary collapse

KEYWORDS =

Ruby keywords

%w[
  ENCODING
  LINE
  FILE
  BEGIN
  END
  alias
  and
  begin
  break
  case
  class
  def
  defined?
  do
  else
  elsif
  end
  ensure
  false
  for
  if
  in
  module
  next
  nil
  not
  or
  redo
  rescue
  retry
  return
  self
  super
  then
  true
  undef
  unless
  until
  when
  while
  yield
].freeze
OTHERS =

Other common but erroneous words in the Ruby-development world

%w[
  asc
  autorun
  autotest
  bigint
  config
  const
  cov
  datetime
  desc
  dir
  env
  formatter
  klass
  rb
  hunspell
  mixin
  param
  sym
  rubymine
  simplecov
  unshift
  xml
  yml
].freeze

Instance Method Summary collapse

Constructor Details

#initializeDefault

Initialize this default dictionary for Ruby code



86
87
88
# File 'lib/alfonsox/spellchecker/dictionary/default.rb', line 86

def initialize
  @words = (KEYWORDS + OTHERS).map(&:downcase)
end

Instance Method Details

#word_present?(word) ⇒ Boolean

Check if a word is present in the dictionary.

Parameters:

  • word (String)

    Word to be checked.

Returns:

  • (Boolean)

    true if the word is in the dictionary, false otherwise.



93
94
95
# File 'lib/alfonsox/spellchecker/dictionary/default.rb', line 93

def word_present?(word)
  @words.include?(word.downcase)
end