Class: GooglePlus::Person
- Inherits:
-
Object
- Object
- GooglePlus::Person
- Extended by:
- Resource
- Includes:
- Entity
- Defined in:
- lib/google_plus/person.rb
Overview
A Person in Google Plus
Constant Summary
Constants included from Resource
Instance Attribute Summary
Attributes included from Entity
Class Method Summary collapse
-
.get(user_id, params = {}) ⇒ GooglePlus::Person
Get a person by id.
-
.list(user_id = 'me', collection = 'visible', params = {}) ⇒ GooglePlus::Cursor
Get a list of people for a collection.
-
.search(query, params = {}) ⇒ GooglePlus::Cursor
Search for a person.
Instance Method Summary collapse
-
#initialize(hash) ⇒ GooglePlus::Person
constructor
Load a new instance from an attributes hash Useful if you have the underlying response data for an object - Generally, what you want is #get though.
-
#list_activities(params = {}) ⇒ GooglePlus::Cursor
List the activities for this person.
-
#list_visible_people(params = {}) ⇒ GooglePlus::Cursor
List visible people for the user.
Methods included from Resource
Methods included from Entity
included, #method_missing, #respond_to?
Constructor Details
#initialize(hash) ⇒ GooglePlus::Person
Load a new instance from an attributes hash Useful if you have the underlying response data for an object - Generally, what you want is #get though
59 60 61 |
# File 'lib/google_plus/person.rb', line 59 def initialize(hash) load_hash(hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GooglePlus::Entity
Class Method Details
.get(user_id, params = {}) ⇒ GooglePlus::Person
Get a person by id
15 16 17 18 |
# File 'lib/google_plus/person.rb', line 15 def self.get(user_id, params = {}) data = make_request(:get, "people/#{user_id}", params) Person.new(JSON.parse(data)) if data end |
.list(user_id = 'me', collection = 'visible', params = {}) ⇒ GooglePlus::Cursor
Get a list of people for a collection
26 27 28 29 30 |
# File 'lib/google_plus/person.rb', line 26 def self.list(user_id = 'me', collection = 'visible', params = {}) path_segments = ['people', user_id, 'people', collection] path = path_segments.map { |ps| URI.escape(ps) }.join('/') GooglePlus::Cursor.new(self, :get, path, params) end |
.search(query, params = {}) ⇒ GooglePlus::Cursor
Search for a person
37 38 39 40 41 |
# File 'lib/google_plus/person.rb', line 37 def self.search(query, params = {}) params[:query] = query resource = 'people' GooglePlus::Cursor.new(self, :get, resource, params) end |
Instance Method Details
#list_activities(params = {}) ⇒ GooglePlus::Cursor
List the activities for this person
45 46 47 |
# File 'lib/google_plus/person.rb', line 45 def list_activities(params = {}) GooglePlus::Activity.for_person(id, params) end |
#list_visible_people(params = {}) ⇒ GooglePlus::Cursor
List visible people for the user
51 52 53 |
# File 'lib/google_plus/person.rb', line 51 def list_visible_people(params = {}) GooglePlus::Person.list('me', 'visible', params) end |