Sha256: e6287c7e3168d04dc6c669a5fd921c9e53ab66f5ede05ee8adf16cbad8c8fe47

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 Bytes

Contents

module FunWith
  module Files
    module Utils
      class TimestampFormat
        # the timestamp identifies a chunk of the filename
        # to be its kind of timestamp by checking it against a 
        # regular expression.  
        def recognizer( regex )
          @recognizer = regex
          self
        end
        
        # The strftime format used to output the timestamp
        def strftime( s )
          @strftime_format = s
          self
        end
        
        def format_time( t )
          t.strftime( @strftime_format )
        end
        
        # does the given chunk look like a timestamp using this format?
        # returns true or false.  
        def matches?( str, &block )
          @recognizer.match( str ) != nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fun_with_files-0.0.18 ./lib/fun_with/files/utils/timestamp_format.rb