module LanguageCards::Helpers::ViewHelper
Public Instance Methods
clear()
click to toggle source
# File lib/language_cards/helpers/view_helper.rb, line 19 def clear printf ::LanguageCards::ESC::CLEAR end
divider()
click to toggle source
# File lib/language_cards/helpers/view_helper.rb, line 4 def divider '~' * SUBMENUWIDTH end
draw(left=nil, center=nil, right=nil)
click to toggle source
# File lib/language_cards/helpers/view_helper.rb, line 12 def draw left=nil, center=nil, right=nil width = SUBMENUWIDTH str = left.to_s str = str + center.to_s.rjust(width/2 - str.length + center.to_s.length/2) str + right.to_s.rjust(width - str.length) end
humanize(string)
click to toggle source
# File lib/language_cards/helpers/view_helper.rb, line 23 def humanize string "#{string}".split('_').map(&:capitalize).join(' ') end
snake(string)
click to toggle source
# File lib/language_cards/helpers/view_helper.rb, line 27 def snake string "#{string}".gsub(/(.)([A-Z])/, '\1_\2').downcase end
t(str)
click to toggle source
# File lib/language_cards/helpers/view_helper.rb, line 8 def t str I18n.t str end
wordwrap(words)
click to toggle source
# File lib/language_cards/helpers/view_helper.rb, line 31 def wordwrap words "#{words}".gsub(/(.{1,#{SUBMENUWIDTH - 7}})(\s+|\Z)/, "\\1\n\t").strip end