Module: Spark::TrialHelper

Defined in:
app/helpers/spark/trial_helper.rb

Instance Method Summary collapse

Instance Method Details

#trialing(end_date, url, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/spark/trial_helper.rb', line 3

def trialing( end_date, url, options={} )

  options[:class] = 'trial-status'

  days = [0, (end_date.to_date - Time.zone.now.to_date).to_i].max
  text = %Q{#{pluralize(days, 'day')} left in trial}

  if days < 1
    options[:class] += ' trial-ended'
  elsif days < 5
    options[:class] += ' trial-ending-soon'
  end

  ( :div, options ) do
    concat ( :span, class: 'trial-status-text' ) { text }
    concat " "
    concat link_to "Manage", url, class: 'trial-status-link'
  end
end