Module: Ocelots::Cli

Includes:
Ocelots
Defined in:
lib/ocelots/cli.rb

Instance Method Summary collapse

Methods included from Ocelots

#base_url, #get, #post, #post_antechamber, #request_antechamber, #request_profile, #url_for

Instance Method Details

#antechamber(team_slug) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ocelots/cli.rb', line 20

def antechamber team_slug
  Thread.new do
    from = 0
    loop do
      messages = request_antechamber team_slug, from
      messages.each do |message|
        from = message['id']
        person = message['person']
        ts = Time.at message['timestamp'].to_i
        puts "#{ts.strftime('%d/%m %H:%M:%S')} #{person['full_name']}: #{message['content']}"
      end
      sleep 5
    end
  end
  loop do
    message = $stdin.gets
    post_antechamber team_slug, message
  end
end

#execute(*args) ⇒ Object



6
7
8
9
# File 'lib/ocelots/cli.rb', line 6

def execute *args
  command, *args = *args
  send command, *args
end

#profile(email) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/ocelots/cli.rb', line 11

def profile email
  response = request_profile email
  if response
    show response, :full_name
    show response, :phone
    show response, :photo_url
  end
end