Module: Dictionary

Defined in:
lib/dictionary.rb,
lib/dictionary/anagram_extractor.rb

Overview

Module that contains the AnagramExtractor.

Defined Under Namespace

Modules: Error Classes: AnagramExtractor

Class Method Summary collapse

Class Method Details

.extract_anagrams(file, export_location, in_c) ⇒ String

Extracts the anagrams from a file, and exports the results.

Parameters:

  • file (String, Pathname)

    the location of the dictionary.

  • export_location (String, Pathname)

    the export location for the results.

  • in_c (true, false)

    run the extraction in C.

Returns:

  • (String)

    The result of the extraction.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dictionary.rb', line 16

def self.extract_anagrams(file, export_location, in_c)
  extractor = AnagramExtractor.new(file)
  extractor.extract! in_c
  extractor.export(export_location)
  "Exported anagram list to #{export_location}."
rescue Error::FileNotFoundError
  "The source file seems to be missing."
rescue Error::PathNotFoundError
  "The export path does not exist."
rescue Error::FileAlreadyExistsError
  "The export file already exists."
end