Sha256: 064f41c42e7d3f1c8b7fa5683c5ba8564c50c2396ec52d5a03dbd5793c5092a5

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Soundcloud
  module Models    
    # Soundcloud Comment resource
    #
    # Look up the resource attributes and filtering usage here:
    #    
    # http://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!', :timestamp => 5000})
    #
    #   # display all comments of some track
    #   some_track.comments.each do |comment| 
    #     p "#{comment.user.full_name} wrote: #{comment.body}"
    #   end  

    class Comment < Base    
      cattr_accessor :element_name    
      belongs_to :user, :track
      self.site = "#{self.site}/tracks/:track_id/"
      self.element_name = 'comment'   
      
      def initialize(options)   
        if not options[:track].nil?
          options[:track_id] = options[:track].id
          options.delete(:track)
        end
        super(options)
      end
      
    end   
        
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
soundcloud-ruby-api-wrapper-0.1.5 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.1.6 lib/soundcloud/models/comment.rb