class TimeCamp::TaskCollection

Public Class Methods

collection?(response) click to toggle source
# File lib/ruby-timecamp/resources/task_collection.rb, line 12
def self.collection?(response)
  # return true if the response is an array
  # or if all of the keys are strings of digits only
  return response.is_a?(Array) || response.keys.all?{ |key| key.scan(/\D/).blank? }
end
new(response) click to toggle source
# File lib/ruby-timecamp/resources/task_collection.rb, line 3
def initialize(response)
  filtered_response = response.map{|k, v| v }
  @resources = filtered_response.map{|task| Task.new(task) }
end
parse(response) click to toggle source
# File lib/ruby-timecamp/resources/task_collection.rb, line 8
def self.parse(response)
  return TimeCamp::TaskCollection.collection?(response) ? TaskCollection.new(response) : Task.new(response)
end