Class: Soundcloud2::Tracks

Inherits:
Client
  • Object
show all
Defined in:
lib/soundcloud2/tracks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Client

#groups, #method_missing, #playlists, #users

Constructor Details

#initialize(*args) ⇒ Tracks

Initialize on the Soundcloud::Client class



6
7
8
# File 'lib/soundcloud2/tracks.rb', line 6

def initialize(*args)
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Soundcloud2::Client

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



3
4
5
# File 'lib/soundcloud2/tracks.rb', line 3

def api_key
  @api_key
end

#connObject (readonly)

Returns the value of attribute conn.



3
4
5
# File 'lib/soundcloud2/tracks.rb', line 3

def conn
  @conn
end

Instance Method Details

#tracks(*args) ⇒ Object

GET /tracks/id a user



11
12
13
14
15
# File 'lib/soundcloud2/tracks.rb', line 11

def tracks(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/tracks/#{args[0]}.json") { |req| req.params = options }
  args.nil? ? response.body.send(sym) : response.body
end

#tracks_comments(*args) ⇒ Object

GET /tracks/id/comments comments for the track GET /tracks/id/comments/comment-id a comment for the track



19
20
21
22
23
24
# File 'lib/soundcloud2/tracks.rb', line 19

def tracks_comments(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/tracks/#{args[0]}/comments.json") { |req| req.params = options }
  args[1].nil? ? (response = conn.get("/tracks/#{args[0]}/comments.json") { |req| req.params = options }) : (response = conn.get("/tracks/#{args[0]}/comments/#{args[1]}.json") { |req| req.params = options })
  args.nil? ? response.body.send(sym) : response.body
end

#tracks_favoriters(*args) ⇒ Object

GET /tracks/id/favoriters users who favorited the track GET /tracks/id/favoriters/user-id a user who has favorited to the track



28
29
30
31
32
# File 'lib/soundcloud2/tracks.rb', line 28

def tracks_favoriters(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  args[1].nil? ? (response = conn.get("/tracks/#{args[0]}/favoriters.json") { |req| req.params = options }) : (response = conn.get("/tracks/#{args[0]}/favoriters/#{args[1]}.json") { |req| req.params = options })
  args.nil? ? response.body.send(sym) : response.body
end

#tracks_secret_token(*args) ⇒ Object

GET /tracks/id/secret-token secret token of the track



35
36
37
38
39
# File 'lib/soundcloud2/tracks.rb', line 35

def tracks_secret_token(*args)
  options = args.extract_options!.merge(:client_id => api_key)
  response = conn.get("/tracks/#{args[0]}/secret-token.json") { |req| req.params = options }
  args.nil? ? response.body.send(sym) : response.body
end