Class: GridCLI::BlockCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- GridCLI::BlockCommand
- Defined in:
- lib/gridcli/commands/block.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#initialize ⇒ BlockCommand
constructor
A new instance of BlockCommand.
- #run(args) ⇒ Object
- #usage ⇒ Object
Methods inherited from BaseCommand
#add_format_option, #add_option, #error, #log, #output_format, #parse_dates, #parse_opts, #pop_arg, #pprint
Constructor Details
#initialize ⇒ BlockCommand
Returns a new instance of BlockCommand.
3 4 5 |
# File 'lib/gridcli/commands/block.rb', line 3 def initialize super "block", "Block a user from further communication" end |
Instance Method Details
#run(args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gridcli/commands/block.rb', line 11 def run(args) # handle options usage if args.length == 0 username = args.shift parse_opts args begin log "Trying to block '#{username}'" Blockage.new(:username => username).save puts "User '#{username}' blocked" rescue ActiveResource::ResourceNotFound puts "Sorry, can't find a user with name '#{username}'" end end |
#usage ⇒ Object
7 8 9 |
# File 'lib/gridcli/commands/block.rb', line 7 def usage super "<username>" end |