Class: Cuiabout::CLI
- Inherits:
-
Object
- Object
- Cuiabout::CLI
- Defined in:
- lib/cuiabout.rb
Constant Summary collapse
- ROOT_PATH =
'http://cui-about.me'
Class Method Summary collapse
- .list(*args) ⇒ Object
- .method_missing(method_or_name, *args) ⇒ Object
- .run(*args) ⇒ Object
- .show(*args) ⇒ Object
- .usage(*args) ⇒ Object (also: help, me)
Class Method Details
.list(*args) ⇒ Object
27 28 29 |
# File 'lib/cuiabout.rb', line 27 def list *args system "curl #{ROOT_PATH}/users" end |
.method_missing(method_or_name, *args) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/cuiabout.rb', line 38 def method_missing method_or_name, *args if listed? method_or_name show method_or_name else abort 'ERROR: Unknown command' end end |
.run(*args) ⇒ Object
10 11 12 13 |
# File 'lib/cuiabout.rb', line 10 def run *args command = args.shift || 'usage' send(command, *args) end |
.show(*args) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/cuiabout.rb', line 31 def show *args abort "ERROR: Please specify user's name" if args.empty? name = args.shift system "curl #{ROOT_PATH}/#{name}" end |
.usage(*args) ⇒ Object Also known as: help, me
15 16 17 18 19 20 21 22 23 |
# File 'lib/cuiabout.rb', line 15 def usage *args puts %( Usage: cuiabout ACTION cuiabout [username] # Prints user's profile cuiabout show [username] # Prints user's profile cuiabout list # Prints all user names ) end |