class SequentialFile::CounterFinder
This class takes a filename and an extension, and finds the counter (Integer) part of the file name
Constants
- NUMBER_REGEX
Public Class Methods
new(filename, extension)
click to toggle source
determines the counter value of the filename passed in. params:
filename - string, complete filename extension - string, the part of the filename that is the extension (e.g. .log or .csv)
# File lib/sequential_file/counter_finder.rb, line 11 def initialize(filename, extension) @filename = File.basename(filename, extension) @length = @filename.length @index_of_extension_separator = @filename.rindex('.') end
Public Instance Methods
counter()
click to toggle source
returns:
an integer representation of the counter
# File lib/sequential_file/counter_finder.rb, line 23 def counter has_extension_separator? ? @filename[@index_of_extension_separator + 1,@length][NUMBER_REGEX].to_i : 0 end
has_extension_separator?()
click to toggle source
# File lib/sequential_file/counter_finder.rb, line 17 def has_extension_separator? !!@index_of_extension_separator end