Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#check_spelling(someword) ⇒ Object

our method to see if a word is spelled correctly



32
33
34
35
36
37
38
39
40
# File 'bin/clispell', line 32

def check_spelling(someword)
    myspeller = new_speller()
    # test [someword] for spelling error and return true if it's correct.
    if myspeller.check(someword)
        return true
    else
        return false
    end
end

#define_word(someword) ⇒ Object

look up a word in the Oxford Advanced Learners Dictionary



26
27
28
29
# File 'bin/clispell', line 26

def define_word(someword)
    facade = OaldParser::Facade.create_configured_instance
    return facade.describe(str: someword)
end

#get_suggestions(someword) ⇒ Object



42
43
44
45
# File 'bin/clispell', line 42

def get_suggestions(someword)
    myspeller = new_speller()
    return myspeller.suggest(someword)
end

#new_dialogObject

helper method for instantiating our dialog API… using this, you only have to configure it in one spot.



17
18
19
20
21
22
23
# File 'bin/clispell', line 17

def new_dialog()
    # instantiate our dialog and set some options
    dialog = RDialog.new
    dialog.nocancel = true
    dialog.shadow = false
    return dialog
end

#new_spellerObject

helper method for instantiating our ASpell API… using this, you only have to configure it in one spot.



8
9
10
11
12
13
# File 'bin/clispell', line 8

def new_speller()
    # instantiate our speller and set the dict to en_US (English - United States) and ignore cAsE.
    speller = Aspell.new("en_US")
    speller.set_option("ignore-case", "true")
    return speller
end

#show_definition(definition) ⇒ Object



54
55
56
# File 'bin/clispell', line 54

def show_definition(definition)
    return new_dialog.msgbox(definition)
end

#show_suggestion_array(suggestions) ⇒ Object



47
48
49
50
51
52
# File 'bin/clispell', line 47

def show_suggestion_array(suggestions)
    # use our new_dialog helper method and call the menu() method on it...
    # ...with our fancy text and suggestions array, then...
    # ...block until the user picks something and return what they picked.
    return new_dialog.menu("Suggested spellings are below.  Select one to view the definition.", suggestions)
end