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.
388 389 390 |
# File 'lib/madeleine.rb', line 388 def initialize(directory_name, id) super(directory_name, "snapshot", id) end |
Class Method Details
.highest_id(directory_name) ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/madeleine.rb', line 369 def self.highest_id(directory_name) return 0 unless File.exist?(directory_name) suffix = "snapshot" highest = 0 Dir.foreach(directory_name) {|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 } highest end |
.next(directory_name) ⇒ Object
384 385 386 |
# File 'lib/madeleine.rb', line 384 def self.next(directory_name) new(directory_name, highest_id(directory_name) + 1) end |