Class: Yourub::Client

Inherits:
Google::APIClient
  • Object
show all
Includes:
MetaSearch
Defined in:
lib/yourub/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MetaSearch

#get, #get_views, #search

Methods included from REST::Videos

list, single_video

Methods included from REST::Categories

for_country

Methods included from REST::Search

list

Constructor Details

#initialize(options = {}) ⇒ Client

The Yourub::Client is a subclass of the Google::APIClient.

In order to initialize the client, you have either to provide a configuration file ‘config/yourub.yml’ in your main application folder or to pass an hash in the initialization. If you don’t provide all the values, default values will be used.The only mandatory value is the developer_key

Examples:

#passing an hash
options = { developer_key: "a_secret_key",
            application_name: "my_app",
            application_version: 2.0,
            log_level: "INFO"}
client = Yourub::Client.new(options)
#assuming that you have a file in config/yourub.yml (see the example in
#the source repository)
client = Yourub::Client.new()

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/yourub/client.rb', line 32

def initialize(options = {})
  unless options.empty?
    Yourub::Config.override_config_file(options)
  end

  args = {
    :key => config.developer_key,
    :application_name => config.application_name,
    :application_version => config.application_version,
    :authorization => nil
  }
  super(args)
end

Instance Attribute Details

#videosObject (readonly)

Returns the value of attribute videos.



8
9
10
# File 'lib/yourub/client.rb', line 8

def videos
  @videos
end

Instance Method Details

#configObject



59
60
61
# File 'lib/yourub/client.rb', line 59

def config
  Yourub::Config
end

#countriesObject



47
48
49
# File 'lib/yourub/client.rb', line 47

def countries
  Yourub::Validator.available_countries
end

#youtube_apiObject

it returns the youtube service object



53
54
55
56
57
# File 'lib/yourub/client.rb', line 53

def youtube_api
  @youtube_api ||= self.discovered_api(
    config.youtube_api_service_name, config.youtube_api_version
  )
end