Class: GooglePlus::Person

Inherits:
Object
  • Object
show all
Extended by:
Resource
Includes:
Entity
Defined in:
lib/google_plus/person.rb

Overview

A Person in Google Plus

Constant Summary

Constants included from Resource

Resource::BASE_URI

Instance Attribute Summary

Attributes included from Entity

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

make_request

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



41
42
43
# File 'lib/google_plus/person.rb', line 41

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

Parameters:

  • user_id (String)

    the id of the user to look up

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :key (Symbol)

    A different API key to use for this request

  • :user_ip (Symbol)

    The IP of the user on who’s behalf this request is made

Returns:

  • (GooglePlus::Person)

    a person object representing the person we’re looking up, if it is found - otherwise, return nil



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

.search(query, params = {}) ⇒ GooglePlus::Cursor

Search for a person

Parameters:

  • query (String)

    The query string to search for

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :key (Symbol)

    A different API key to use for this request

  • :user_ip (Symbol)

    The IP of the user on who’s behalf this request is made

Returns:



25
26
27
28
29
# File 'lib/google_plus/person.rb', line 25

def self.search(query, params = {})
  params[:query] = URI.escape(query)
  resource = 'people'
  GooglePlus::Cursor.new(self, :get, resource, params)
end

Instance Method Details

#list_activitiesGooglePlus::Cursor

List the activities for this person

Returns:



33
34
35
# File 'lib/google_plus/person.rb', line 33

def list_activities
  GooglePlus::Activity.for_person(id)
end