Module: ApplicationHelper

Defined in:
lib/generators/templates/app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#check(data) ⇒ Object

Substitute N/A for blank data



51
52
53
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 51

def check(data)
	data.blank? ? 'N/A' : data
end

#date_compact(date) ⇒ Object

Date: 1/1/2012



68
69
70
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 68

def date_compact(date)
	date.strftime("%-m/%-d/%Y") if !date.blank?
end

#date_short(date) ⇒ Object

Date: Jan 1, 2012



60
61
62
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 60

def date_short(date)
	date.strftime("%b %e, %Y") if !date.blank?
end

#enabled_disabled(bool) ⇒ Object

Enabled -or- Disabled



43
44
45
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 43

def enabled_disabled(bool)
	bool ? 'Enabled' : 'Disabled'
end

#exists?(data) ⇒ Boolean

Substitute empty string for blank data

Returns:

  • (Boolean)


76
77
78
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 76

def exists?(data)
	data.blank? ? '' : data
end

#icon(key) ⇒ Object

Display IcoMoon font icon



27
28
29
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 27

def icon key
  raw "<i data-icon=&#x#{h(key)}></i>"
end

#mdebug(object) ⇒ Object

Alternate object debug



88
89
90
91
92
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 88

def mdebug(object)
	d = object.attributes.inspect.split(',')
	d.map! {|i| i.to_s + '<br>'}
	d.join.delete("{").delete("}")
end

#title(title_partials) ⇒ Object

Accepts a String or Array. Sets yield(:title) to a String for use in <title>.

--Array--
title ["Example", "Nashville, TN"]
=> "Example - Page - Title"

--String--
title "Example Page Title"
=> "Example Page Title"


15
16
17
18
19
20
21
22
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 15

def title title_partials
  title = if title_partials.is_a? String
    title_partials
  elsif title_partials.is_a? Array
    title_partials.reject(&:blank?).join(' - ')
  end
  content_for(:title) { title }
end

#yes_no(bool) ⇒ Object

Yes -or- No



35
36
37
# File 'lib/generators/templates/app/helpers/application_helper.rb', line 35

def yes_no(bool)
	bool ? 'Yes' : 'No'
end