Sha256: b3c0009d76211718b73e62d8637f74f2dee0731779a150311bf6bd54e459c184

Contents?: true

Size: 923 Bytes

Versions: 107

Compression:

Stored size: 923 Bytes

Contents

require 'nkf'

module Daddy
  module Utils
    class StringUtils

      def self.to_hiragana(s)
        return s if is_empty(s)
        NKF::nkf('-Ww --hiragana', s)
      end
    
      def self.to_katakana(s)
        return s if is_empty(s)
        NKF::nkf('-Ww --katakana', s)
      end
    
      def self.to_zen(s)
        return s if is_empty(s)
        NKF::nkf('-WwXm0', s)
      end
    
      def self.to_han(s)
        return s if is_empty(s)
        NKF::nkf('-Wwxm0Z0', s)
      end
    
      def self.current_time(now = nil)
        now = Time.now unless now
        now.instance_eval { '%s%03d' % [strftime('%Y%m%d%H%M%S'), (usec / 1000.0).round] }
      end
    
      def self.rand(length = 8)
        chars = ("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a
        ret = []
        length.times do |i|
          ret[i] = chars[rand(chars.size)]
        end
        ret.join
      end

    end
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
daddy-0.9.9 lib/daddy/utils/string_utils.rb
daddy-0.9.8 lib/daddy/utils/string_utils.rb
daddy-0.9.7 lib/daddy/utils/string_utils.rb
daddy-0.9.6 lib/daddy/utils/string_utils.rb
daddy-0.9.5 lib/daddy/utils/string_utils.rb
daddy-0.9.4 lib/daddy/utils/string_utils.rb
daddy-0.9.3 lib/daddy/utils/string_utils.rb
daddy-0.9.2 lib/daddy/utils/string_utils.rb
daddy-0.9.1 lib/daddy/utils/string_utils.rb
daddy-0.9.0 lib/daddy/utils/string_utils.rb
daddy-0.8.1 lib/daddy/utils/string_utils.rb
daddy-0.8.0 lib/daddy/utils/string_utils.rb
daddy-0.7.9 lib/daddy/utils/string_utils.rb
daddy-0.7.8 lib/daddy/utils/string_utils.rb
daddy-0.7.7 lib/daddy/utils/string_utils.rb
daddy-0.7.6 lib/daddy/utils/string_utils.rb
daddy-0.7.5 lib/daddy/utils/string_utils.rb
daddy-0.7.4 lib/daddy/utils/string_utils.rb
daddy-0.7.3 lib/daddy/utils/string_utils.rb
daddy-0.7.2 lib/daddy/utils/string_utils.rb