Class: Ghaki::Namer::Base
- Inherits:
-
Object
- Object
- Ghaki::Namer::Base
- Defined in:
- lib/ghaki/namer/base.rb
Direct Known Subclasses
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
-
#rand_stamp ⇒ Object
Returns the value of attribute rand_stamp.
-
#rand_stamp_max ⇒ Object
Returns the value of attribute rand_stamp_max.
-
#ticket_generator ⇒ Object
Returns the value of attribute ticket_generator.
-
#time_stamp ⇒ Object
Returns the value of attribute time_stamp.
Instance Method Summary collapse
- #debug_dump(out_file) ⇒ Object
-
#initialize(opts = {}) ⇒ Base
constructor
A new instance of Base.
- #parse_names(*get_pile) ⇒ Object
- #ticket ⇒ Object
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_stamp ⇒ Object
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_max ⇒ Object
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_generator ⇒ Object
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_stamp ⇒ Object
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 |
#ticket ⇒ Object
33 34 35 |
# File 'lib/ghaki/namer/base.rb', line 33 def ticket @ticket ||= parse_names( *@ticket_generator).join('') end |