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

Version Path
gemwarrior-0.10.6 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.10.5 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.10.4 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.10.2 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.10.1 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.10.0 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.39 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.37 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.36 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.35 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.34 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.33 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.32 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.31 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.30 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.28 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.27 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.26 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.24 lib/gemwarrior/misc/formatting.rb
gemwarrior-0.9.23 lib/gemwarrior/misc/formatting.rb