Sha256: 995e637648f9c5aff6834fe9eb6ed8a7398e3dea20b5099b044801f0bb566eaf
Contents?: true
Size: 943 Bytes
Versions: 32
Compression:
Stored size: 943 Bytes
Contents
# lib/gemwarrior/misc/formatting.rb # Formatting methods for text module Gemwarrior module Formatting def self.upstyle(str_arr) if str_arr.is_a? Array str_arr_upstyled = [] str_arr.each do |str_arr_item| str_arr_item_upstyled = [] str_arr_item.split(' ').each do |s| str_arr_item_upstyled << upstyle_string(s) end str_arr_upstyled << str_arr_item_upstyled.join(' ') end return str_arr_upstyled else return upstyle_string(str_arr) end end private def self.upstyle_string(s) s_upstyle = '' s_upstyle << s[0].upcase 1.upto(s.length-1) do |i| if s[i-1].eql?('_') s_upstyle[i-1] = ' ' s_upstyle << s[i].upcase else s_upstyle << s[i].downcase end end return s_upstyle end end end
Version data entries
32 entries across 32 versions & 1 rubygems