Class: Todoable::Item
- Inherits:
-
Object
- Object
- Todoable::Item
- Defined in:
- lib/todoable/item.rb
Constant Summary collapse
- ITEM_PATH =
"/items/"- FINISH_PATH =
"/finish"
Instance Attribute Summary collapse
-
#list_id ⇒ Object
Returns the value of attribute list_id.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #create(content) ⇒ Object
- #delete(item_id) ⇒ Object
- #finish(item_id) ⇒ Object
-
#initialize(user, list_id) ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize(user, list_id) ⇒ Item
Returns a new instance of Item.
8 9 10 11 |
# File 'lib/todoable/item.rb', line 8 def initialize(user, list_id) @user = user @list_id = list_id end |
Instance Attribute Details
#list_id ⇒ Object
Returns the value of attribute list_id.
6 7 8 |
# File 'lib/todoable/item.rb', line 6 def list_id @list_id end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/todoable/item.rb', line 6 def user @user end |
Instance Method Details
#create(content) ⇒ Object
13 14 15 |
# File 'lib/todoable/item.rb', line 13 def create(content) user.make_request(LISTS_PATH+list_id+ITEM_PATH, :post, { item: {name: content} }) end |
#delete(item_id) ⇒ Object
21 22 23 |
# File 'lib/todoable/item.rb', line 21 def delete(item_id) user.make_request(LISTS_PATH+list_id+ITEM_PATH+item_id, :delete) end |
#finish(item_id) ⇒ Object
17 18 19 |
# File 'lib/todoable/item.rb', line 17 def finish(item_id) user.make_request(LISTS_PATH+list_id+ITEM_PATH+item_id+FINISH_PATH, :put) end |