Class: Urban::CLI
- Inherits:
-
Object
- Object
- Urban::CLI
- Defined in:
- lib/urban/cli.rb
Instance Attribute Summary collapse
-
#dictionary ⇒ Object
Returns the value of attribute dictionary.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run(args = ARGV) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
10 11 12 |
# File 'lib/urban/cli.rb', line 10 def initialize @dictionary = Urban::Dictionary.new end |
Instance Attribute Details
#dictionary ⇒ Object
Returns the value of attribute dictionary.
8 9 10 |
# File 'lib/urban/cli.rb', line 8 def dictionary @dictionary end |
Instance Method Details
#run(args = ARGV) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/urban/cli.rb', line 14 def run(args = ARGV) = parse(args) results = lookup() case when results.definitions generate_output results, when results.phrase error "no definitions found for #{results.phrase.upcase}." else $stdout.puts .version ? version : usage end rescue SocketError error "no internet connection available." rescue OptionParser::InvalidOption => e error "#{e.}\nTry `urban --help' for more information." rescue Object => e error e. end |