Class: Lastfm
- Inherits:
-
Object
- Object
- Lastfm
- Defined in:
- lib/lastfm.rb,
lib/lastfm/util.rb,
lib/lastfm/response.rb,
lib/lastfm/method_category/geo.rb,
lib/lastfm/method_category/tag.rb,
lib/lastfm/method_category/auth.rb,
lib/lastfm/method_category/base.rb,
lib/lastfm/method_category/user.rb,
lib/lastfm/method_category/album.rb,
lib/lastfm/method_category/chart.rb,
lib/lastfm/method_category/event.rb,
lib/lastfm/method_category/group.rb,
lib/lastfm/method_category/radio.rb,
lib/lastfm/method_category/track.rb,
lib/lastfm/method_category/artist.rb,
lib/lastfm/method_category/library.rb,
lib/lastfm/method_category/tasteometer.rb
Defined Under Namespace
Modules: MethodCategory Classes: AnyParams, ApiError, Error, Response, Util
Instance Attribute Summary collapse
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
- #album ⇒ Object
- #artist ⇒ Object
- #auth ⇒ Object
- #chart ⇒ Object
- #event ⇒ Object
- #geo ⇒ Object
- #group ⇒ Object
-
#initialize(api_key, api_secret) ⇒ Lastfm
constructor
A new instance of Lastfm.
- #library ⇒ Object
- #radio ⇒ Object
- #request(method, params = {}, http_method = :get, with_signature = false, with_session = false, use_https = false) ⇒ Object
- #tag ⇒ Object
- #tasteometer ⇒ Object
- #track ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(api_key, api_secret) ⇒ Lastfm
Returns a new instance of Lastfm.
38 39 40 41 |
# File 'lib/lastfm.rb', line 38 def initialize(api_key, api_secret) @api_key = api_key @api_secret = api_secret end |
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
26 27 28 |
# File 'lib/lastfm.rb', line 26 def session @session end |
Instance Method Details
#album ⇒ Object
43 44 45 |
# File 'lib/lastfm.rb', line 43 def album MethodCategory::Album.new(self) end |
#artist ⇒ Object
47 48 49 |
# File 'lib/lastfm.rb', line 47 def artist MethodCategory::Artist.new(self) end |
#auth ⇒ Object
51 52 53 |
# File 'lib/lastfm.rb', line 51 def auth MethodCategory::Auth.new(self) end |
#chart ⇒ Object
87 88 89 |
# File 'lib/lastfm.rb', line 87 def chart MethodCategory::Chart.new(self) end |
#event ⇒ Object
55 56 57 |
# File 'lib/lastfm.rb', line 55 def event MethodCategory::Event.new(self) end |
#geo ⇒ Object
59 60 61 |
# File 'lib/lastfm.rb', line 59 def geo MethodCategory::Geo.new(self) end |
#group ⇒ Object
63 64 65 |
# File 'lib/lastfm.rb', line 63 def group MethodCategory::Group.new(self) end |
#library ⇒ Object
67 68 69 |
# File 'lib/lastfm.rb', line 67 def library MethodCategory::Library.new(self) end |
#radio ⇒ Object
91 92 93 |
# File 'lib/lastfm.rb', line 91 def radio MethodCategory::Radio.new(self) end |
#request(method, params = {}, http_method = :get, with_signature = false, with_session = false, use_https = false) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/lastfm.rb', line 95 def request(method, params = {}, http_method = :get, with_signature = false, with_session = false, use_https = false) params[:method] = method params[:api_key] = @api_key params.each do |k, v| if v.nil? params.delete(k) end end # http://www.lastfm.jp/group/Last.fm+Web+Services/forum/21604/_/497978 #params[:format] = format params.update(:sk => @session) if with_session params.update(:api_sig => Digest::MD5.hexdigest(build_method_signature(params))) if with_signature request_args = [http_method, '/', { (http_method == :post ? :body : :query) => params }] response = if use_https HTTPSRequest.send(*request_args) else HTTPRequest.send(*request_args) end response = Response.new(response.body) unless response.success? raise ApiError.new(response., response.error) end response end |
#tag ⇒ Object
71 72 73 |
# File 'lib/lastfm.rb', line 71 def tag MethodCategory::Tag.new(self) end |
#tasteometer ⇒ Object
75 76 77 |
# File 'lib/lastfm.rb', line 75 def tasteometer MethodCategory::Tasteometer.new(self) end |
#track ⇒ Object
79 80 81 |
# File 'lib/lastfm.rb', line 79 def track MethodCategory::Track.new(self) end |
#user ⇒ Object
83 84 85 |
# File 'lib/lastfm.rb', line 83 def user MethodCategory::User.new(self) end |