Class: Contactually::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/contactually.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Tasks

Returns a new instance of Tasks.



9
10
11
# File 'lib/contactually.rb', line 9

def initialize(api_key)
  @connection = Connection.new(api_key)
end

Instance Method Details

#listObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/contactually.rb', line 13

def list
  tasks = @connection.tasks_list
  rows = []
  tasks["tasks"].each do |t|
    if t['completed_at'].nil?
      time = Time.parse(t['due_date'])
      rows << [time.strftime('%e %b'), t['associated_contact']['full_name'], t['title']]
    end
  end
  table = Terminal::Table.new :rows => rows
  puts table
end