Class: Maildir::UniqueName
- Inherits:
-
Object
- Object
- Maildir::UniqueName
- Defined in:
- lib/maildir/unique_name.rb
Overview
Class for generating unique file names for new messages
Class Method Summary collapse
-
.counter ⇒ Object
Return a thread-safe increasing counter.
- .create ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ UniqueName
constructor
Return a unique file name based on strategy.
-
#to_s ⇒ Object
Return the name as a string.
Constructor Details
#initialize ⇒ UniqueName
Return a unique file name based on strategy
20 21 22 23 |
# File 'lib/maildir/unique_name.rb', line 20 def initialize # Use the same time object @now = Time.now end |
Class Method Details
.counter ⇒ Object
Return a thread-safe increasing counter
7 8 9 10 11 12 |
# File 'lib/maildir/unique_name.rb', line 7 def counter @counter_mutex ||= Mutex.new @counter_mutex.synchronize do @counter = @counter.to_i + 1 end end |
.create ⇒ Object
14 15 16 |
# File 'lib/maildir/unique_name.rb', line 14 def create self.new.to_s end |
Instance Method Details
#to_s ⇒ Object
Return the name as a string
26 27 28 |
# File 'lib/maildir/unique_name.rb', line 26 def to_s [left, middle, right].join(".") end |