Sha256: 34cb52149ab57dd3572119fc1cb574dcc64a0f61a36625101781b783b7fe3959

Contents?: true

Size: 462 Bytes

Versions: 10

Compression:

Stored size: 462 Bytes

Contents

module ConsadoleAggregator
  class Helper
    def self.concat text, opt=Hash.new('')
      base = "#{text} #{opt[:url]} #{opt[:hashtag]}".squeeze(' ').rstrip
      if base.size > 140
        over_size = base.size - 140
        concat(omit(text, over_size), opt)
      else
        base
      end
    end

    private
    def self.omit text, over_size
      truncated = text.slice(0...-over_size)
      truncated[-3..-1] = '...'
      truncated
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
consadole_aggregator-0.1.9 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.8 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.7 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.6 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.5 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.4 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.3 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.2 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.1 lib/consadole_aggregator/helper.rb
consadole_aggregator-0.1.0 lib/consadole_aggregator/helper.rb