Class: GridCLI::LikeCommand

Inherits:
BaseCommand show all
Defined in:
lib/gridcli/commands/like.rb

Instance Attribute Summary

Attributes inherited from BaseCommand

#cmd, #desc

Instance Method Summary collapse

Methods inherited from BaseCommand

#add_format_option, #add_option, #error, #log, #output_format, #parse_dates, #parse_opts, #pop_arg, #pprint

Constructor Details

#initializeLikeCommand

Returns a new instance of LikeCommand.



3
4
5
6
# File 'lib/gridcli/commands/like.rb', line 3

def initialize
  super "like", "Like something. Specify friends/subgrids to restrict recipients."
  add_format_option
end

Instance Method Details

#run(args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gridcli/commands/like.rb', line 12

def run(args)
  usage if args.length == 0
  body = args.shift
  recipients = pop_arg(args, "friends")
  parse_opts args

  begin
    log "Trying to send a like '#{body}' to your friends"
    post = Post::Like.create :body => body, :recipients => recipients, :posttype => 'like'
  rescue ActiveResource::ClientError
    puts "There was an error sending your like.  Please make sure it's not empty."
    return
  end

  puts "Like posted."
end

#usageObject



8
9
10
# File 'lib/gridcli/commands/like.rb', line 8

def usage
  super "<like> [<username>[,<username>]]"
end