Class: Foursquared::Response::Tip
- Inherits:
-
Object
- Object
- Foursquared::Response::Tip
- Defined in:
- lib/foursquared/response/tip.rb
Overview
Tip response class
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#canonical_url ⇒ String
The canonical url for the tip.
-
#created_at ⇒ Time
Time since creation of the tip.
-
#done ⇒ Hash
Users who have done this tip todo.
-
#id ⇒ String
ID of the tip.
-
#initialize(client, response) ⇒ Tip
constructor
A new instance of Tip.
-
#like(options = {}) ⇒ Hash
Like or unlike the tip.
-
#like? ⇒ Boolean
Whether the acting user likes the tip.
-
#likes ⇒ Hash
Groups of users who like the tip.
-
#listed ⇒ Hash
Groups of lists.
-
#mark_done ⇒ Foursquared::Response::Tip
Mark the tip done.
-
#mark_todo ⇒ Foursquared::Response::Todo
Mark the tip to-do.
-
#photo ⇒ Foursquared::Response::Photo
Photo for this tip.
-
#status ⇒ String
Status of this tip.
-
#text ⇒ String
The actual tip.
-
#todo ⇒ Hash
Users who have marked this tip todo.
-
#unmark_todo(tip_id) ⇒ Foursquared::Response::Tip
Unmark the tip as to-do.
-
#url ⇒ String
A URL for more information.
-
#user ⇒ Foursquared::Response::User
If the context allows tips from multiple venues, the compact venue for this tip.
-
#venue ⇒ Foursquared::Response::Venue
If the context allows tips from multiple venues, the compact venue for this tip.
Constructor Details
#initialize(client, response) ⇒ Tip
Returns a new instance of Tip.
6 7 8 9 |
# File 'lib/foursquared/response/tip.rb', line 6 def initialize client, response @client = client @response = response end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/foursquared/response/tip.rb', line 5 def client @client end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/foursquared/response/tip.rb', line 5 def response @response end |
Instance Method Details
#canonical_url ⇒ String
The canonical url for the tip
31 32 33 |
# File 'lib/foursquared/response/tip.rb', line 31 def canonical_url response["canonicalUrl"] end |
#created_at ⇒ Time
Time since creation of the tip
19 20 21 |
# File 'lib/foursquared/response/tip.rb', line 19 def created_at Time.at(response["createdAt"]) if response["createdAt"] end |
#done ⇒ Hash
Users who have done this tip todo
95 96 97 98 |
# File 'lib/foursquared/response/tip.rb', line 95 def done @done = response["done"] @done["groups"].each {|group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @done and @done["groups"] end |
#id ⇒ String
ID of the tip
13 14 15 |
# File 'lib/foursquared/response/tip.rb', line 13 def id response["id"] end |
#like(options = {}) ⇒ Hash
Like or unlike the tip
104 105 106 107 108 109 |
# File 'lib/foursquared/response/tip.rb', line 104 def like ={} response = post("/tips/#{id}/like", )["response"] @likes = response["likes"] @likes["groups"].each{ |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes["groups"] @likes end |
#like? ⇒ Boolean
Whether the acting user likes the tip
44 45 46 |
# File 'lib/foursquared/response/tip.rb', line 44 def like? response["like"] end |
#likes ⇒ Hash
Groups of users who like the tip
37 38 39 40 |
# File 'lib/foursquared/response/tip.rb', line 37 def likes @likes = response["likes"] @likes["groups"].each{ |group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes["groups"] end |
#listed ⇒ Hash
Groups of lists
62 63 64 65 66 |
# File 'lib/foursquared/response/tip.rb', line 62 def listed @listed = response["listed"] @listed["groups"].each{|group| group["items"].map!{|item| Foursquared::Response::List.new(client, item)}} if @listed and @listed["groups"] end |
#mark_done ⇒ Foursquared::Response::Tip
Mark the tip done
113 114 115 116 |
# File 'lib/foursquared/response/tip.rb', line 113 def mark_done response = post("/tips/#{id}/markdone")["response"] Foursquared::Response::Tip.new(self, response["tip"]) end |
#mark_todo ⇒ Foursquared::Response::Todo
Mark the tip to-do
120 121 122 123 |
# File 'lib/foursquared/response/tip.rb', line 120 def mark_todo response = post("/tips/#{id}/marktodo")["response"] Foursquared::Response::Todo.new(self, response["todo"]) end |
#photo ⇒ Foursquared::Response::Photo
Photo for this tip
70 71 72 |
# File 'lib/foursquared/response/tip.rb', line 70 def photo Foursquared::Response::Photo.new(client, response["photo"]) if response["photo"] end |
#status ⇒ String
Status of this tip.
76 77 78 |
# File 'lib/foursquared/response/tip.rb', line 76 def status response["status"] end |
#text ⇒ String
The actual tip
25 26 27 |
# File 'lib/foursquared/response/tip.rb', line 25 def text response["text"] end |
#todo ⇒ Hash
Users who have marked this tip todo
88 89 90 91 |
# File 'lib/foursquared/response/tip.rb', line 88 def todo @todo = response["todo"] @todo["groups"].each {|group| group["items"].map!{|item| Foursquared::Response::User.new(client, item)}} if @todo and @todo["groups"] end |
#unmark_todo(tip_id) ⇒ Foursquared::Response::Tip
Unmark the tip as to-do
127 128 129 130 |
# File 'lib/foursquared/response/tip.rb', line 127 def unmark_todo tip_id response = post("/tips/#{tip_id}/unmark")["response"] Foursquared::Response::Tip.new(self, response["tip"]) end |
#url ⇒ String
A URL for more information.
82 83 84 |
# File 'lib/foursquared/response/tip.rb', line 82 def url response["url"] end |
#user ⇒ Foursquared::Response::User
If the context allows tips from multiple venues, the compact venue for this tip.
56 57 58 |
# File 'lib/foursquared/response/tip.rb', line 56 def user Foursquared::Response::User.new(client, response["user"]) if response["user"] end |
#venue ⇒ Foursquared::Response::Venue
If the context allows tips from multiple venues, the compact venue for this tip.
50 51 52 |
# File 'lib/foursquared/response/tip.rb', line 50 def venue Foursquared::Response::Venue.new(client, response["venue"]) if response["venue"] end |