Class: Soundcloud::Models::Comment

Inherits:
Base
  • Object
show all
Defined in:
lib/soundcloud/models/comment.rb

Overview

SC API Attributes (as of 26/05/09):

  • body

  • timestamp

  • id

  • track_id

  • user_id

  • uri

Custom Wrapper Attributes/Methods:

  • user

  • track

Look up the resource attributes and filtering usage here:

wiki.github.com/soundcloud/api/documentation#comment

Examples:

# add a comment to a track
some_track = sc_client.Track.find('some-track')
sc_client.Comment.create({:track => some_track, :body => 'Nice Track!'})

# optionally you can add a timestamp (in milliseconds)
sc_client.Comment.create({:track => some_track, :body => 'nice drums @ the 5th second!', :timestamp => 5000})

# display all comments of some track
some_track.comments.each do |comment| 
  p "#{comment.user.full_name} wrote: #{comment.body}"
end

Instance Method Summary (collapse)

Methods inherited from Base

can_be_a_single_changeable, connection, has_many_single_changeable, #send_files

Constructor Details

- (Comment) initialize(options)



40
41
42
43
44
45
46
# File 'lib/soundcloud/models/comment.rb', line 40

def initialize(options)   
  if not options[:track].nil?
    options[:track_id] = options[:track].id
    options.delete(:track)
  end
  super(options)
end