Class: Preference

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/preference.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.due_stylesObject



5
6
7
# File 'app/models/preference.rb', line 5

def self.due_styles
  { :due_in_n_days => 0, :due_on => 1}
end

Instance Method Details

#format_date(date) ⇒ Object



28
29
30
# File 'app/models/preference.rb', line 28

def format_date (date)
  return date ? date.in_time_zone(time_zone).strftime("#{date_format}") : ''
end

#hide_completed_actions?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/models/preference.rb', line 9

def hide_completed_actions?
  return show_number_completed == 0
end

#parse_date(s) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/preference.rb', line 13

def parse_date(s)
  return nil if s.blank?
  date = nil

  if s.is_a?(Time)
    date = s.to_date
  elsif s.is_a?(String)
    date = Date.strptime(s, date_format)
  else
    raise ArgumentError.new("Bad argument type:#{s.class}")
  end

  date.in_time_zone(time_zone).beginning_of_day
end