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