Sha256: a1d9fafa0f73ef582b698d4a91bee16f0b76d41d00c0a2e0f5f275775ee19b56

Contents?: true

Size: 1.36 KB

Versions: 15

Compression:

Stored size: 1.36 KB

Contents

module Soundcloud
  module Models   
    # 
    # 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:
    #         
    # 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 @ 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  

    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

15 entries across 15 versions & 1 rubygems

Version Path
soundcloud-ruby-api-wrapper-0.1.8 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.1.9 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.2.0 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.2.1 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.3.1 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.3.2 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.3.3 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.3.4 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.4.0 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.4.1 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.4.8 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.4.7 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.4.6 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.4.5 lib/soundcloud/models/comment.rb
soundcloud-ruby-api-wrapper-0.4.4 lib/soundcloud/models/comment.rb