lib/rufus/rtm/resources.rb in rufus-rtm-0.1.2 vs lib/rufus/rtm/resources.rb in rufus-rtm-0.1.3
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2008-2009, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2008-2010, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -36,11 +36,10 @@
@hsh = hsh
@operations = []
end
- #
# Saves the instance back to RTM.
#
def save!
# TODO : compact !
@@ -52,11 +51,10 @@
@operations = []
end
protected
- #
# a class method for listing attributes that can be found
# in the hash reply coming from RTM...
#
def self.milk_attr (*att_names) #:nodoc:
@@ -67,38 +65,34 @@
end
}
end
end
- #
# Calls the milk() method (interacts with the RTM API).
#
def self.execute (method_name, args={})
args[:method] = "rtm.#{resource_name}.#{method_name}"
Rufus::RTM.milk(args)
end
- #
# Returns the name of the resource as the API knows it
# (for example 'tasks' or 'lists').
#
def self.resource_name
self.to_s.split('::')[-1].downcase + 's'
end
- #
# Simply calls the timeline() class method.
#
def timeline
MilkResource.timeline
end
- #
# Returns the current timeline (fetches one if none has yet
# been prepared).
#
def self.timeline
@@ -164,27 +158,24 @@
@task_id = t['id']
@tags = TagArray.new(self, h['tags'])
end
- #
# Deletes the task.
#
def delete!
self.class.execute('delete', prepare_api_args)
end
- #
# Marks the task as completed.
#
def complete!
self.class.execute('complete', prepare_api_args)
end
- #
# Sets the tags for the task.
#
def tags= (tags)
tags = tags.split(',') if tags.is_a?(String)
@@ -197,10 +188,9 @@
def self.find (params={})
parse_tasks(execute('getList', params))
end
- #
# Adds a new task (and returns it).
#
def self.add! (name, list_id=nil)
args = {}