Sha256: 35058705a1db51fc1ece57e4f5c0b509c331f01ea7c0d49a71bea3167b836b5f

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

#!/usr/bin/env ruby -KU
require 'urban_dictionary'
require 'optparse'

options = {}
option_parser = OptionParser.new do |opts|
  opts.banner = "Usage: urban_dictionary <word or phrase>"
  opts.version = UrbanDictionary::VERSION

  opts.on("-r", "--random", "Define a random word") do |r|
    options[:random] = r
  end
end
option_parser.parse(ARGV)

if ARGV.empty? && !options[:random]
  puts option_parser.help
  exit(0)
end

word = if options[:random]
  UrbanDictionary.random_word
else
  UrbanDictionary.define(ARGV.join(" "))
end

output = []
output << word
output << '-' * word.size
output << ''
word.entries.each_with_index do |entry, i|
  output << "#{i + 1}. #{entry.definition}"
  output << ""
  output << "Example: #{entry.example}"
  output << ""
  output << ""
end
puts output.join("\n")

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
urban_dictionary-0.0.2 bin/urban_dictionary
urban_dictionary-0.0.1 bin/urban_dictionary