Module: Scholar::Utilities::Formatters

Included in:
Scholar::Utilities
Defined in:
lib/scholar/utilities/formatters.rb

Overview

String formatters.

Instance Method Summary collapse

Instance Method Details

#capitalize(str) ⇒ Object

Capitalize the first character of a String.



10
11
12
# File 'lib/scholar/utilities/formatters.rb', line 10

def capitalize(str)
  str.to_s.capitalize
end

#carets(str) ⇒ Object

Add carets (<>) around String.



15
16
17
# File 'lib/scholar/utilities/formatters.rb', line 15

def carets(str)
  "&#60;#{str.to_s}&#62;"
end

#colon(str) ⇒ Object

Add a colon to the end of a String.



20
21
22
# File 'lib/scholar/utilities/formatters.rb', line 20

def colon(str)
  "#{str.to_s}:"
end

#comma(str) ⇒ Object

Add a comma to the end of a String.



25
26
27
# File 'lib/scholar/utilities/formatters.rb', line 25

def comma(str)
  "#{str.to_s},"
end

#italicize(str) ⇒ Object

Add <em> tags around a String to italicize it.



30
31
32
# File 'lib/scholar/utilities/formatters.rb', line 30

def italicize(str)
  "<em>#{str.to_s}</em>"
end

#ordinal(int) ⇒ Object

Return the ordinal form of an integer (1 turns into 1st, etc).



35
36
37
# File 'lib/scholar/utilities/formatters.rb', line 35

def ordinal(int)
  ActiveSupport::Inflector.ordinalize(int.to_i)
end

#period(str) ⇒ Object

Add a period to the end of a String.



40
41
42
# File 'lib/scholar/utilities/formatters.rb', line 40

def period(str)
  "#{str.to_s}."
end

#quotes(str) ⇒ Object

Wrap a String in quotes.



45
46
47
# File 'lib/scholar/utilities/formatters.rb', line 45

def quotes(str)
  "&#8220;#{str.to_s}&#8221;"
end

#replace(str) ⇒ Object

Replace with a String.



50
51
52
# File 'lib/scholar/utilities/formatters.rb', line 50

def replace(str)
  str.to_s
end

#underline(str) ⇒ Object

Add <u> tags around a String to italicize it.



55
56
57
# File 'lib/scholar/utilities/formatters.rb', line 55

def underline(str)
  "<u>#{str.to_s}</u>"
end