Skip to content

Instantly share code, notes, and snippets.

@ecin
Created June 1, 2010 17:01
Show Gist options
  • Save ecin/421168 to your computer and use it in GitHub Desktop.
Save ecin/421168 to your computer and use it in GitHub Desktop.
# Figured out by Craig on the macruby-devel mailing list
framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/DictionaryServices.framework'
word = 'History'
word_len = DCSGetTermRangeInString(nil, word, 0);
result = DCSCopyTextDefinition(nil, word, word_len)
puts "Definition for: #{word}"
puts result
# Or in module form...
module Definable
def definition
range = DCSGetTermRangeInString(nil, self.to_s, 0);
DCSCopyTextDefinition(nil, self.to_s, range)
end
def define
puts self.definition
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment