Sha256: 0baa23cdb0240e42a80861faee9504c51b026a26cb80de82e245a0a16c5e35e6

Contents?: true

Size: 704 Bytes

Versions: 5

Compression:

Stored size: 704 Bytes

Contents

module MessageTrain
  # Application helper
  module ApplicationHelper
    def message_train_widget
      render partial: 'message_train/application/widget'
    end

    def fuzzy_date(date)
      time = Time.parse(date.strftime('%F %T'))
      change_in_time = Time.now - time
      return :just_now.l if (0..1.minute).cover? change_in_time
      l(time, format: fuzzy_date_format(change_in_time))
    end

    private

    def fuzzy_date_format(change_in_time)
      case change_in_time
      when 1.minute..1.day
        :fuzzy_today
      when 1.day..1.week
        :fuzzy_this_week
      when 1.week..1.year
        :fuzzy_date_without_year
      else
        :fuzzy_date
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
message_train-0.7.6 app/helpers/message_train/application_helper.rb
message_train-0.7.5 app/helpers/message_train/application_helper.rb
message_train-0.7.3 app/helpers/message_train/application_helper.rb
message_train-0.7.2 app/helpers/message_train/application_helper.rb
message_train-0.7.1 app/helpers/message_train/application_helper.rb