class Lastfm::MethodCategory::Base
Public Class Methods
__define_method(method, id, params, &block)
click to toggle source
# File lib/lastfm/method_category/base.rb, line 39 def __define_method(method, id, params, &block) unless block block = Proc.new { |response| response.xml } end define_method(id) do |*args| block.call( send( method, id.to_s.gsub(/_[a-z]/){ |s| s[1].upcase }, Lastfm::Util.build_options( args, params[:required], params[:optional] ) ) ) end end
any_params(*args)
click to toggle source
# File lib/lastfm/method_category/base.rb, line 13 def any_params(*args) AnyParams.new(args) end
method_for_authentication(id, params = {}, &block)
click to toggle source
# File lib/lastfm/method_category/base.rb, line 27 def method_for_authentication(id, params = {}, &block) __define_method(:request_for_authentication, id, params, &block) end
method_for_secure_authentication(id, params = {}, &block)
click to toggle source
# File lib/lastfm/method_category/base.rb, line 31 def method_for_secure_authentication(id, params = {}, &block) __define_method(:request_for_secure_authentication, id, params, &block) end
method_with_authentication(id, params = {}, &block)
click to toggle source
# File lib/lastfm/method_category/base.rb, line 23 def method_with_authentication(id, params = {}, &block) __define_method(:request_with_authentication, id, params, &block) end
new(lastfm)
click to toggle source
# File lib/lastfm/method_category/base.rb, line 60 def initialize(lastfm) @lastfm = lastfm end
regular_method(id, params = {}, &block)
click to toggle source
# File lib/lastfm/method_category/base.rb, line 35 def regular_method(id, params = {}, &block) __define_method(:request, id, params, &block) end
write_method(id, params = {})
click to toggle source
# File lib/lastfm/method_category/base.rb, line 17 def write_method(id, params = {}) __define_method(:write_request, id, params) do |response| response.success? end end
Public Instance Methods
request(*args)
click to toggle source
# File lib/lastfm/method_category/base.rb, line 80 def request(*args) method, *rest = args method = [self.class.name.split(/::/).last.downcase, method].join('.') @lastfm.request(method, *rest) end
request_for_authentication(method, params = {})
click to toggle source
# File lib/lastfm/method_category/base.rb, line 72 def request_for_authentication(method, params = {}) request(method, params, :get, true) end
request_for_secure_authentication(method, params = {})
click to toggle source
# File lib/lastfm/method_category/base.rb, line 76 def request_for_secure_authentication(method, params = {}) request(method, params, :post, true, false, true) end
request_with_authentication(method, params = {})
click to toggle source
# File lib/lastfm/method_category/base.rb, line 68 def request_with_authentication(method, params = {}) request(method, params, :get, true, true) end
write_request(method, params = {})
click to toggle source
# File lib/lastfm/method_category/base.rb, line 64 def write_request(method, params = {}) request(method, params, :post, true, true) end