Class: Ghaki::Namer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ghaki/namer/base.rb

Direct Known Subclasses

Files::Base

Constant Summary collapse

TIME_STAMP_FMT =
'%Y%m%d_%H%M%S'
RAND_STAMP_MAX =

FFFF+1

65536
RAND_STAMP_FMT =
'%04x'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Base

Returns a new instance of Base.



16
17
18
19
20
21
# File 'lib/ghaki/namer/base.rb', line 16

def initialize opts={}
  @time_stamp     = opts[:time_stamp]     || Time.now
  @rand_stamp_max = opts[:rand_stamp_max] || RAND_STAMP_MAX
  @rand_stamp     = opts[:rand_stamp]     || rand(@rand_stamp_max)
  @ticket_generator = opts[:ticket_generator]
end

Instance Attribute Details

#rand_stampObject

Returns the value of attribute rand_stamp.



12
13
14
# File 'lib/ghaki/namer/base.rb', line 12

def rand_stamp
  @rand_stamp
end

#rand_stamp_maxObject

Returns the value of attribute rand_stamp_max.



12
13
14
# File 'lib/ghaki/namer/base.rb', line 12

def rand_stamp_max
  @rand_stamp_max
end

#ticket_generatorObject

Returns the value of attribute ticket_generator.



12
13
14
# File 'lib/ghaki/namer/base.rb', line 12

def ticket_generator
  @ticket_generator
end

#time_stampObject

Returns the value of attribute time_stamp.



12
13
14
# File 'lib/ghaki/namer/base.rb', line 12

def time_stamp
  @time_stamp
end

Instance Method Details

#debug_dump(out_file) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/ghaki/namer/base.rb', line 38

def debug_dump out_file
  out_file.box 'debug ' + self.class.to_s
  out_file.reindent({
    :time_stamp => self.time_stamp,
    :rand_stamp => self.rand_stamp,
    :rand_stamp_max => self.rand_stamp_max,
    :ticket_generator => self.ticket_generator,
  }.inspect)
end

#parse_names(*get_pile) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/ghaki/namer/base.rb', line 24

def parse_names *get_pile
  put_pile = []
  get_pile.each do |item|
    _parse_item put_pile, item
  end
  put_pile
end

#ticketObject



33
34
35
# File 'lib/ghaki/namer/base.rb', line 33

def ticket
  @ticket ||= parse_names( *@ticket_generator).join('')
end