Sha256: 250163768198988d525f86045c26182164a2be76aff4f12ef8a443bcc5d973a6

Contents?: true

Size: 668 Bytes

Versions: 5

Compression:

Stored size: 668 Bytes

Contents

module WWMD
  class WWMDUtils

    def self.header_array_from_file(filename)
      ret = Hash.new
      File.readlines(filename).each do |line|
        a = line.chomp.split(/\t/,2)
        ret[a[0]] = a[1]
      end
      return ret
    end

    def self.ranstr(len=8,digits=false)
      chars = ("a".."z").to_a
      chars += ("0".."9").to_a if digits
      ret = ""
      1.upto(len) { |i| ret << chars[rand(chars.size-1)] }
      return ret
    end

    def self.rannum(len=8,hex=false)
      chars = ("0".."9").to_a
      chars += ("A".."F").to_a if hex
      ret = ""
      1.upto(len) { |i| ret << chars[rand(chars.size-1)] }
      return ret
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
miketracy-wwmd-0.2.11 lib/wwmd/page/utils.rb
miketracy-wwmd-0.2.12 lib/wwmd/page/utils.rb
miketracy-wwmd-0.2.14 lib/wwmd/wwmd_utils.rb
miketracy-wwmd-0.2.15 lib/wwmd/wwmd_utils.rb
miketracy-wwmd-0.2.16 lib/wwmd/wwmd_utils.rb