Class: SessionIdGenerator

Inherits:
Object
  • Object
show all
Defined in:
app/session_id_generator.rb

Instance Method Summary collapse

Instance Method Details

#format_to_length(value, len) ⇒ Object



13
14
15
# File 'app/session_id_generator.rb', line 13

def format_to_length value, len
	value.to_s.rjust len,"0"
end

#generate_id(time = Time.new) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'app/session_id_generator.rb', line 3

def generate_id time=Time.new
year = format_to_length time.year, 4
month = format_to_length time.month, 2
day = format_to_length time.day, 2
hour = format_to_length time.hour, 2
minute = format_to_length time.min, 2
second = format_to_length time.sec, 2
  "#{year}-#{month}-#{day}_#{hour}-#{minute}-#{second}"
end