Class: Shareable::Helpers::Twitter

Inherits:
Socialize show all
Defined in:
lib/shareable/helpers/tags.rb

Instance Method Summary collapse

Methods inherited from Tag

#initialize

Constructor Details

This class inherits a constructor from Shareable::Helpers::Tag

Instance Method Details

#to_s(locals = {}) ⇒ Object

:nodoc:


141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/shareable/helpers/tags.rb', line 141

def to_s(locals={}) #:nodoc:
  locals[:options] ||= {}
  if locals[:options][:text].blank? && @options[:options][:text].blank? && (@options[:twitter] ? @options[:twitter][:text].blank? : true) && @options[:options][:title]
    locals[:options][:text] = @options[:options][:title]
  end
  if (@options[:options][:static_link] && !(@options[:twitter] && @options[:twitter][:static_link]==false)) || (@options[:twitter] && @options[:twitter][:static_link])
    p_opts = {:text => CGI::escape(locals[:options][:text] ? locals[:options][:text] : (@options[:options][:text] ? @options[:options][:text] : '')),
              :url => CGI::escape(@options[:options][:url]),
              :hashtags => @options[:options][:hashtags].blank? ? '' : @options[:options][:hashtags].split(',').map{|tag| CGI::escape(tag)}.join(',')}
    locals[:options].merge!(@options[:options].merge(p_opts))
    if @options[:twitter]
      @options[:twitter][:text] = CGI::escape(@options[:twitter][:text]) if @options[:twitter][:text]
      @options[:twitter][:url] = CGI::escape(@options[:twitter][:url]) if @options[:twitter][:url]
      @options[:twitter][:hashtags] = @options[:twitter][:hashtags].split(',').map{|tag| CGI::escape(tag)}.join(',') if @options[:twitter][:hashtags]
    end
  end
  super locals, "Twitter"
end