class AlfonsoX::SpellChecker::Dictionary::Rubymine
Rubymine
dictionary loader
Constants
- DEFAULT_PATH
Default
directory where the XML RubyMine dictionary file should be
Attributes
path[R]
Public Class Methods
from_config(yml_config)
click to toggle source
Load configuration from YML
# File lib/alfonsox/spellchecker/dictionary/rubymine.rb, line 25 def self.from_config(yml_config) new(yml_config.fetch('path') { DEFAULT_PATH }) end
new(path = nil)
click to toggle source
Initialize Rubymine
dictionary If path is not present, it will be loaded from #DEFAULT_PATH.
# File lib/alfonsox/spellchecker/dictionary/rubymine.rb, line 19 def initialize(path = nil) @path = path || DEFAULT_PATH load_dictionaries end
Public Instance Methods
word_present?(word)
click to toggle source
Inform if a word is present in this dictionary.
# File lib/alfonsox/spellchecker/dictionary/rubymine.rb, line 30 def word_present?(word) @words.include?(word.downcase) end
Private Instance Methods
load_dictionaries()
click to toggle source
# File lib/alfonsox/spellchecker/dictionary/rubymine.rb, line 36 def load_dictionaries @words = Set.new Dir.glob("#{@path}/*.xml") do |xml_file_path| xml_file_contents = ::File.open(xml_file_path).read xml_doc = ::Nokogiri::XML(xml_file_contents) xml_doc.css('w').each do |word| @words.add(word.content.downcase) end end @words end