Sha256: df963740807c430bdb12318ad2a9e94d66a2c403b5e73772649f6c48d0ef7d1c

Contents?: true

Size: 367 Bytes

Versions: 22

Compression:

Stored size: 367 Bytes

Contents

module Lopata
  module Id
    extend self

    def next(prefix = nil)
      id = "%d_%d" % [timestamp, seq_num]
      id = "%s_%s" % [prefix, id] if prefix
      id
    end

    def timestamp
      @timestamp ||= Time.now.strftime("%Y%m%d%H%M%S")
    end

    def seq_num
      @seq_num ||= 0
      @seq_num += 1
      @seq_num
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lopata-0.1.6 lib/lopata/id.rb
lopata-0.1.5 lib/lopata/id.rb
lopata-0.1.4 lib/lopata/id.rb
lopata-0.1.3 lib/lopata/id.rb
lopata-0.1.2 lib/lopata/id.rb
lopata-0.1.1 lib/lopata/id.rb
lopata-0.1.0 lib/lopata/id.rb
lopata-0.0.16 lib/lopata/id.rb
lopata-0.0.15 lib/lopata/id.rb
lopata-0.0.14 lib/lopata/id.rb
lopata-0.0.13 lib/lopata/id.rb
lopata-0.0.12 lib/lopata/id.rb
lopata-0.0.11 lib/lopata/id.rb
lopata-0.0.10 lib/lopata/id.rb
lopata-0.0.9 lib/lopata/id.rb
lopata-0.0.8 lib/lopata/id.rb
lopata-0.0.7 lib/lopata/id.rb
lopata-0.0.6 lib/lopata/id.rb
lopata-0.0.5 lib/lopata/id.rb
lopata-0.0.4 lib/lopata/id.rb