app/models/observation.rb
# share this (and any subsequent) observations on twitter
# if we're sharing more than one observation, this aggregates them into one tweet
share this (and any subsequent) observations on twitter
if we're sharing more than one observation, this aggregates them into one tweet
share this ( and any subsequent ) observations on twitter if we ' re sharing more than one observation this aggregates them into one tweet
def share_on_twitter(options = {})
    u = self.user
    twit_api = u.twitter_api
    return nil unless twit_api
    observations_to_share = if options[:single]
      [self]
    else
      Observation.where(:user_id => u.id).where(["id >= ?", id]).limit(100)
    end
    observations_to_share_count = observations_to_share.count
    tweet_text = "I added "
    tweet_text += observations_to_share_count > 1 ? "#{observations_to_share_count} observations" : "an observation"
    url = if observations_to_share_count == 1
      FakeView.observation_url(self)
    else
      dates = observations_to_share.map(&:observed_on).uniq.compact
      if dates.size == 1
        d = dates.first
        FakeView.calendar_date_url(u.login, d.year, d.month, d.day)
      else
        FakeView.observations_by_login_url(u.login)
      end
    end
    url = if url =~ /\?/
      "#{url}&#{id}"
    else
      "#{url}?#{id}"
    end
    tweet_text += " to #{SITE_NAME} #{url}"
    twit_api.update(tweet_text)
  end
def share_on_twitter ( options = { } ) u = self . user twit_api = u . twitter_api return nil unless twit_api observations_to_share = if options [ :single ] [ self ] else Observation . where ( :user_id => u . id ) . where ( [ "id >= ?" , id ] ) . limit ( 100 ) end observations_to_share_count = observations_to_share . count tweet_text = "I added " tweet_text += observations_to_share_count > 1 ? "#{observations_to_share_count} observations" : "an observation" url = if observations_to_share_count == 1 FakeView . observation_url ( self ) else dates = observations_to_share . map ( & :observed_on ) . uniq . compact if dates . size == 1 d = dates . first FakeView . calendar_date_url ( u . login , d . year , d . month , d . day ) else FakeView . observations_by_login_url ( u . login ) end end url = if url =~ / \? / "#{url}&#{id}" else "#{url}?#{id}" end tweet_text += " to #{SITE_NAME} #{url}" twit_api . update ( tweet_text ) end
share this (and any subsequent) observations on twitter
if we're sharing more than one observation, this aggregates them into one tweet
share this ( and any subsequent ) observations on twitter if we ' re sharing more than one observation this aggregates them into one tweet
options