### Home Classes Methods

### In Files

- lib/last_fm/request.rb

### Parent

Object

### Methods

- ::album_request
- ::api_key=
- ::artist_request
- ::base_uri
- ::chart_request
- ::create_and_queue_request
- ::current_class_name
- ::default_params
- ::handle_response
- ::results
- ::run_queue!
- ::track_request
- ::update_results

### Files

- README_FOR_APP

### Class Index

Quicksearch

- LastFM
- LastFM::Album
- LastFM::Artist
- LastFM::Chart
- LastFM::Request
- LastFM::Track
- LastFM::Validator
- DeviseAuth
- DeviseAuth::RegistrationsController
- DeviseAuth::SessionsController
- Users
- Users::OmniauthCallbacksController
- ApplicationController
- ApplicationHelper
- Artist
- ArtistsController
- ChartsController
- HomeController
- Playlist
- PlaylistsTracks
- RedisQueryable
- SearchController
- Track
- TracksController
- User
- UsersController
- UsersHelper
- YoutubeVideoRating

No matching classes.

# LastFM::Request

### Public Class Methods

album_request(method, node, q, artist = nil, limit = nil, page = nil, &block) click to toggle source

        # File lib/last_fm/request.rb, line 42
    42:     def self.album_request method, node, q, artist = nil, limit = nil, page = nil, &block

    43:       request_params = default_params.merge( :method => "#{current_class_name}.#{method}", :album => q, :artist => artist, :limit => limit, :page => page )

    44:       create_and_queue_request method, node, block, request_params

    45:     end

api_key=(key) click to toggle source

        # File lib/last_fm/request.rb, line 13
    13:     def self.api_key=(key)

    14:       @@api_key = key

    15:       @@default_params[:api_key] = key

    16:     end

artist_request(method, node, q, limit = nil, page = nil, &block) click to toggle source

        # File lib/last_fm/request.rb, line 37
    37:     def self.artist_request method, node, q, limit = nil, page = nil, &block

    38:       request_params = default_params.merge( :method => "#{current_class_name}.#{method}", :artist => q, :limit => limit, :page => page )

    39:       create_and_queue_request method, node, block, request_params

    40:     end

base_uri() click to toggle source

        # File lib/last_fm/request.rb, line 18
    18:     def self.base_uri

    19:       @@base_uri

    20:     end

chart_request(method, node, limit = nil, page = nil, &block) click to toggle source

        # File lib/last_fm/request.rb, line 52
    52:     def self.chart_request method, node, limit = nil, page = nil, &block

    53:       request_params = default_params.merge( :method => "#{current_class_name}.#{method}", :limit => limit, :page => page )

    54:       create_and_queue_request method, node, block, request_params

    55:     end

default_params() click to toggle source

        # File lib/last_fm/request.rb, line 22
    22:     def self.default_params

    23:       @@default_params

    24:     end

results(keys = nil) click to toggle source

        # File lib/last_fm/request.rb, line 26
    26:     def self.results keys = nil

    27:       return @@results if keys.nil?

    28:       @@results[("#{keys[0]}_#{keys[1]}".to_sym)]

    29:     end

run_queue!() click to toggle source

        # File lib/last_fm/request.rb, line 31
    31:     def self.run_queue!

    32:       puts "=> lastfm: Started request queue"

    33:       @@hydra.run

    34:       puts "=> lastfm: Queue finished"

    35:     end

track_request(method, node, q, artist = nil, limit = nil, page = nil, &block) click to toggle source

        # File lib/last_fm/request.rb, line 47
    47:     def self.track_request method, node, q, artist = nil, limit = nil, page = nil, &block

    48:       request_params = default_params.merge( :method => "#{current_class_name}.#{method}", :track => q, :artist => artist, :limit => limit, :page => page )

    49:       create_and_queue_request method, node, block, request_params

    50:     end

### Protected Class Methods

current_class_name() click to toggle source

        # File lib/last_fm/request.rb, line 63
    63:     def self.current_class_name

    64:       self.name.split('::').last.downcase!

    65:     end

update_results(keys, hash) click to toggle source

        # File lib/last_fm/request.rb, line 59
    59:     def self.update_results keys, hash

    60:       @@results[("#{keys[0]}_#{keys[1]}".to_sym)].update hash

    61:     end

### Private Class Methods

create_and_queue_request(method, node, block, request_params) click to toggle source

        # File lib/last_fm/request.rb, line 69
    69:     def self.create_and_queue_request method, node, block, request_params

    70:       request = Typhoeus::Request.new(base_uri, :params => request_params) # :timeout => APP_CONFIG["request_timeout"],

    71:       handle_response request, method, node, block

    72:

    73:       puts "=> lastfm: '#{current_class_name}.#{method}' request is queued" if @@hydra.queue request

    74:       @@results["#{current_class_name}_#{method}".to_sym] = Hashie::Mash.new

    75:     end

handle_response(request, method, node, block) click to toggle source

        # File lib/last_fm/request.rb, line 77
    77:     def self.handle_response request, method, node, block

    78:       request.on_complete do |response|

    79:         if response.success?

    80:           puts "=> lastfm: '#{current_class_name}.#{method}' (#{response.time}s)"

    81:

    82:           hash = Hashie::Mash.new(JSON.parse(response.body))

    83:           hash = method.to_s == "search" ? hash.results.send(node.to_sym) : hash.send(node.to_sym)

    84:

    85:           update_results [current_class_name, method], hash if hash.present? and block.nil?

    86:           block.call( hash ) unless block.nil?

    87:

    88:         elsif response.timed_out?

    89:           puts "=> lastfm: '#{current_class_name}.#{method}' timed out"

    90:         end

    91:       end

    92:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.