Class: Madeleine::SnapshotFile
- Inherits:
-
NumberedFile
- Object
- NumberedFile
- Madeleine::SnapshotFile
- Defined in:
- lib/madeleine.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(directory_name, id) ⇒ SnapshotFile
constructor
A new instance of SnapshotFile.
Methods inherited from NumberedFile
Constructor Details
#initialize(directory_name, id) ⇒ SnapshotFile
Returns a new instance of SnapshotFile.
399 400 401 |
# File 'lib/madeleine.rb', line 399 def initialize(directory_name, id) super(directory_name, "snapshot", id) end |
Class Method Details
.highest_id(directory_name) ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/madeleine.rb', line 380 def self.highest_id(directory_name) return 0 unless File.exist?(directory_name) suffix = "snapshot" highest = 0 Dir.foreach(directory_name) do |file_name| match = /^(\d{#{FILE_COUNTER_SIZE}}\.#{suffix}$)/.match(file_name) next unless match n = match[1].to_i if n > highest highest = n end end highest end |
.next(directory_name) ⇒ Object
395 396 397 |
# File 'lib/madeleine.rb', line 395 def self.next(directory_name) new(directory_name, highest_id(directory_name) + 1) end |