class Gnip::Message

  1. lib/gnip_api/gnip/message.rb
Superclass: Object

Constants

SYSTEM_MESSAGE_TYPES = ['error', 'warn', 'info']  
TWITTER_COMPLIANCE_MESSAGES = ['delete', 'user_delete', 'user_undelete', 'scrub_geo', 'user_protect', 'user_unprotect', 'user_suspend', 'user_unsuspend', 'user_withheld', 'status_withheld']  

Public Class methods

build (params)
[show source]
# File lib/gnip_api/gnip/message.rb, line 8
def self.build params
  return build_system_message(params) if (SYSTEM_MESSAGE_TYPES & params.keys).any?
  return build_twitter_compliance_message(params) if TWITTER_COMPLIANCE_MESSAGES.include? params['verb']
  return build_activity(params) if params['objectType'] && params['objectType'] == 'activity'
  raise Gnip::UndefinedMessage
end

Public Instance methods

activity? ()
[show source]
# File lib/gnip_api/gnip/message.rb, line 35
def activity?
  @object_type == 'activity'
end
compliance_message? ()
[show source]
# File lib/gnip_api/gnip/message.rb, line 19
def compliance_message?
  GnipApi::Gnip::Message::TWITTER_COMPLIANCE_MESSAGES.include? @object_type
end
error? ()
[show source]
# File lib/gnip_api/gnip/message.rb, line 23
def error?
  @message_type == 'error'
end
generate_json (data)
[show source]
# File lib/gnip_api/gnip/message.rb, line 39
def generate_json data
  GnipApi::JsonParser.new.encode(data)
end
info? ()
[show source]
# File lib/gnip_api/gnip/message.rb, line 31
def info?
  @message_type == 'info'
end
system_message? ()
[show source]
# File lib/gnip_api/gnip/message.rb, line 15
def system_message?
  @message_type ? true : false
end
warn? ()
[show source]
# File lib/gnip_api/gnip/message.rb, line 27
def warn?
  @message_type == 'warn'
end