Class: Atig::Command::Favorite

Inherits:
Command
  • Object
show all
Defined in:
lib/atig/command/favorite.rb

Instance Attribute Summary

Attributes inherited from Command

#api, #db, #gateway, #opts

Instance Method Summary collapse

Methods inherited from Command

#find_by_tid

Constructor Details

#initialize(*args) ⇒ Favorite

Returns a new instance of Favorite.



8
# File 'lib/atig/command/favorite.rb', line 8

def initialize(*args); super end

Instance Method Details

#action(target, mesg, command, args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/atig/command/favorite.rb', line 11

def action(target, mesg, command, args)
  method   = { 'fav' => 'create', 'unfav' => 'destroy' }[command]

  args.each do|tid|
    if entry = Info.find_status(db, tid)
      api.delay(0){|t|
        t.post("favorites/#{method}", {id: entry.status.id})
        yield "#{command.upcase}: #{entry.user.screen_name}: #{entry.status.text}"
      }
    else
      yield "No such ID : #{tid}"
    end
  end
end

#command_nameObject



9
# File 'lib/atig/command/favorite.rb', line 9

def command_name; %w(fav unfav) end