Top Level Namespace
Instance Method Summary collapse
-
#check_spelling(someword) ⇒ Object
check the spelling of a word and return boolean.
-
#copy_to_clipboard(something) ⇒ Object
copy [something] to the clipboard (works on OSX/Linux/Win)…
-
#define_word(someword) ⇒ Object
look up a word in the Oxford Advanced Learners Dictionary.
-
#get_suggestions(someword) ⇒ Object
get an array of possible corrections.
-
#new_dialog ⇒ Object
helper method for instantiating our dialog API…
-
#new_speller ⇒ Object
helper method for instantiating our ASpell API…
-
#show_definition(definition) ⇒ Object
show a dialog box with the definition.
-
#show_suggestion_array(orig_word, suggestions) ⇒ Object
show a dialog menu with all the possible corrections.
Instance Method Details
#check_spelling(someword) ⇒ Object
check the spelling of a word and return boolean.
63 64 65 66 67 68 69 70 71 |
# File 'bin/clispell', line 63 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 |
#copy_to_clipboard(something) ⇒ Object
copy [something] to the clipboard (works on OSX/Linux/Win)… …if we have the flag set to enable that.
75 76 77 78 79 80 |
# File 'bin/clispell', line 75 def copy_to_clipboard(something) if $enable_copy_to_clipboard Clipboard.copy(something) puts "Copied #{something} to the clipboard." end end |
#define_word(someword) ⇒ Object
look up a word in the Oxford Advanced Learners Dictionary
54 55 56 57 58 59 60 |
# File 'bin/clispell', line 54 def define_word(someword) # use the Facade interface from the oald_parser gem... # ...which does the scraping / parsing for us. puts "Waiting for the definition of #{someword} (requires internet access)..." facade = OaldParser::Facade.create_configured_instance return facade.describe(str: someword) end |
#get_suggestions(someword) ⇒ Object
get an array of possible corrections.
83 84 85 86 |
# File 'bin/clispell', line 83 def get_suggestions(someword) myspeller = new_speller() return myspeller.suggest(someword) end |
#new_dialog ⇒ Object
helper method for instantiating our dialog API… using this, you only have to configure it in one spot.
44 45 46 47 48 49 50 51 |
# File 'bin/clispell', line 44 def new_dialog() # instantiate our dialog and set some options... # ...then return it as an object dialog = RDialog.new dialog.nocancel = true dialog.shadow = false return dialog end |
#new_speller ⇒ Object
helper method for instantiating our ASpell API… using this, you only have to configure it in one spot.
34 35 36 37 38 39 40 |
# File 'bin/clispell', line 34 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
show a dialog box with the definition.
97 98 99 |
# File 'bin/clispell', line 97 def show_definition(definition) return new_dialog.msgbox(definition) end |
#show_suggestion_array(orig_word, suggestions) ⇒ Object
show a dialog menu with all the possible corrections
89 90 91 92 93 94 |
# File 'bin/clispell', line 89 def show_suggestion_array(orig_word,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.("#{orig_word} not found or spelled incorrectly.\nSelect a word below view the definition.", suggestions) end |