Class: TwitterAPI

Inherits:
IsprasAPI show all
Defined in:
lib/ispras-api/twitter_api.rb

Constant Summary

Constants inherited from IsprasAPI

IsprasAPI::ROOT_URL

Instance Method Summary collapse

Methods inherited from IsprasAPI

#GET, #POST

Constructor Details

#initialize(key, name = nil, ver = nil) ⇒ TwitterAPI

Returns a new instance of TwitterAPI.



10
11
12
13
14
# File 'lib/ispras-api/twitter_api.rb', line 10

def initialize(key, name = nil, ver = nil)
  name = 'twitter-nlp' if name.nil? || name.empty?
  ver = '1.0' if ver.nil? || ver.empty?
  super(key, name, ver)
end

Instance Method Details

#custom_query(path, query, form = nil) ⇒ Object



31
32
33
# File 'lib/ispras-api/twitter_api.rb', line 31

def custom_query(path, query, form = nil)
  form.nil? ? GET(path, query) : POST(path, query, form)
end

#extract_dde(params) ⇒ Hash

Extracts demographic attributes from provided Twitter info. All info is required, but can be empty

Parameters:

  • params (Hash)

Options Hash (params):

  • :lang (String)

    Language of tweets

  • :username (String)

    Username of Twitter user

  • :screenname (String)

    Screen name of Twitter user

  • :description (String)

    Description of Twitter user

  • :tweet (String, Array<String>)

    User’s tweets

Returns:

  • (Hash)

    Enriched user with attributes



26
27
28
29
# File 'lib/ispras-api/twitter_api.rb', line 26

def extract_dde(params)
  params[:tweet] = params[:tweet].join(' ') if params[:tweet].is_a? Array
  POST 'extract', {}, params
end