Module: Safai::Helpers
- Defined in:
- lib/safai.rb
Overview
Instance Method Summary collapse
- #amt2(c, amount) ⇒ Object
- #f(ff) ⇒ Object
- #location_map(u) ⇒ Object
- #location_summary(u) ⇒ Object
- #location_summary_short(u) ⇒ Object
- #smart_date(i, mode = "date") ⇒ Object
- #smart_due_date(i) ⇒ Object
- #title(page_title) ⇒ Object
Instance Method Details
#amt2(c, amount) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/safai.rb', line 67 def amt2(c, amount) m = Money::Currency.new(c) amount = sprintf("%0.02f", amount) if !m.blank? if !m.symbol.blank? return "#{m.symbol} #{amount.to_s}".html_safe end end return "#{c} #{amount.to_s}" end |
#f(ff) ⇒ Object
19 20 21 |
# File 'lib/safai.rb', line 19 def f(ff) sprintf("%0.02f", ff) end |
#location_map(u) ⇒ Object
63 64 65 |
# File 'lib/safai.rb', line 63 def location_map(u) return Safai::Address.map(u, 300, 95) end |
#location_summary(u) ⇒ Object
55 56 57 |
# File 'lib/safai.rb', line 55 def location_summary(u) return Safai::Address.to_s(u) end |
#location_summary_short(u) ⇒ Object
59 60 61 |
# File 'lib/safai.rb', line 59 def location_summary_short(u) return Safai::Address.gist(u) end |
#smart_date(i, mode = "date") ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/safai.rb', line 27 def smart_date(i, mode="date") if i.blank? return "" elsif (i.class.to_s == "Time" or i.class.to_s == "ActiveSupport::TimeWithZone") and mode == "time" return i.year == Time.now.year ? i.strftime("%d-%b %H:%M") : i.strftime("%d-%b-%Y %H:%M") else return i.year == Time.now.year ? i.strftime("%d-%b") : i.strftime("%d-%b-%Y") end end |
#smart_due_date(i) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/safai.rb', line 37 def smart_due_date(i) if i == nil return "" elsif i.class.to_s == "Time" or i.class.to_s == "ActiveSupport::TimeWithZone" i = i.to_date end if Date.today == i return "<span style=\"background-color:#F7FAB9;padding:0px 2px 0px 2px;\">Today</span>" elsif i - Date.today == 1 return "<span style=\"background-color:#F7FAB9;padding:0px 2px 0px 2px;\">Tomorrow</span>" elsif Date.today - i > 0.9 return "<span style=\"background-color:#FFC7C7;padding:0px 2px 0px 2px;\">" + smart_date(i) + "</span>" elsif Date.today - i < 1 return "<span style=\"background-color:#D2FFCC;padding:0px 2px 0px 2px;\">" + smart_date(i) + "</span>" end return smart_date(i) end |
#title(page_title) ⇒ Object
23 24 25 |
# File 'lib/safai.rb', line 23 def title(page_title) content_for(:title) { page_title } end |