(function($) {
  var defaults = {
    user: false,
    count: 1
  };
  
  
  $.fn.tweet = function(opts) {
    opts = $.extend({}, defaults, opts);
    return this.each(function() {
      new Tweet(this, opts);
    });
  };
  
  
  
  function Tweet (el, opts) {
    this.el   = $(el); 
    this.opts = opts;
    
    this.init();
  };
  
  Tweet.prototype.extend = $.extend;
  Tweet.prototype.extend({
    init: function() {
      this.el.html('Cargando...');
      
      
      var self = this;
      $.getJSON('http://api.twitter.com/1/statuses/user_timeline.json?callback=?',
                { screen_name: this.opts.user, count: this.opts.count },
                function(data, status) {
                  self.el.html(data.length ? data[0].text : 'No hay tweets')
                });
      
      
    }
  });
  
  
})(jQuery);
