Module: Lookup
- Defined in:
- lib/lookup.rb
Class Method Summary collapse
Class Method Details
.fetch_definition(word) ⇒ Object
3 4 5 6 |
# File 'lib/lookup.rb', line 3 def self.fetch_definition word definitions = `dict "#{word}" 2>/dev/null | grep ' ' | head -2`.chomp.gsub(" ","").split(/[\r\n]/) definitions.uniq.join(" -- ") end |
.go(words) ⇒ Object
12 13 14 |
# File 'lib/lookup.rb', line 12 def self.go words words.map{|w| sanitize w}.map{|w| "#{w}\t#{fetch_definition w}"}.join("\n") end |
.sanitize(word) ⇒ Object
8 9 10 |
# File 'lib/lookup.rb', line 8 def self.sanitize word word.gsub(/[,\.]/,"") end |