class Gosquared::Trends

Constants

BASEURL
DIMENSIONS

Public Class Methods

new(api_key, site_token, client = Gosquared::Client.new) click to toggle source
# File lib/gosquared/trends.rb, line 11
def initialize(api_key, site_token, client = Gosquared::Client.new)
  @site_token = site_token
  @api_key = api_key
  @client = client
 end

Public Instance Methods

fetch() click to toggle source
# File lib/gosquared/trends.rb, line 31
def fetch
  data = @client.get(url)
  @@filters.each { |key, _value| @@filters[key] = nil } if data
  data
 end

Private Instance Methods

camelize(key) click to toggle source
# File lib/gosquared/trends.rb, line 47
def camelize(key)
  key.split('_').each_with_index.map { |fragment, index| index == 0 ? fragment : fragment.capitalize }.join('')
 end
url() click to toggle source
# File lib/gosquared/trends.rb, line 39
def url
  array = ['']
  url = BASEURL + @dimension + "?api_key=#{@api_key}" + "&site_token=#{@site_token}"
  @@filters.each { |key, value| array << "#{camelize(key.to_s)}=#{value}" if value }
  parameters = array.join('&')
  url.concat(parameters)
 end