Class: GooglePlus::Comment

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

Overview

A Comment 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::Comment

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



34
35
36
# File 'lib/google_plus/comment.rb', line 34

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

.for_activity(activity_id, params = {}) ⇒ GooglePlus::Cursor

Get a cursor of comments for an activity

Parameters:

  • activity_id (String)

    The id of the activity to look up comments 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
# File 'lib/google_plus/comment.rb', line 25

def self.for_activity(activity_id, params = {})
  resource = "activities/#{activity_id}/comments"
  GooglePlus::Cursor.new(self, :get, resource, params)
end

.get(comment_id, params = {}) ⇒ GooglePlus::Comment

Get a comment by id

Parameters:

  • comment_id (String)

    The id of the comment 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::Comment)

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



15
16
17
18
# File 'lib/google_plus/comment.rb', line 15

def self.get(comment_id, params = {})
  data = make_request(:get, "comments/#{comment_id}", params)
  Comment.new(JSON.parse(data)) if data
end